Reply
Posts: 1
Registered: ‎09-11-2017

EZR32LG - deactivate EZRadio without reset

 Hello everyone,this is my first project with a silebs chip and i hope for help.

 

I want to build a magnet sensor module. A Reed Switch monitors the open/close State of a window and i want to decrease the avr. power consumtion of the Chip. (actual: 2mA)

The Idea:
Every 30 seconds the µC leaves EM2 and checks the state of the reed switch.

Only if the switch state changes: activate EZRadio -> send Package -> deactivate EZRadio

and again entering EM2.

I am using the SLWSTK6200A Kit with the EZR32LG330F256R60 and primarily the existing ezradio_simple_trx example and i just change some points for my purpose.

Currently the code only works if the ezradioInit() function is called befor entering the while loop (like in the example) so the Radio is allways on.

How can i de-/activate the Radio without a chip reset and how get it in the while loop?

 

I hope this is understandable and sorry for my english

 

Thanks in advance!

Sebastian

 

int main(void)
{
  /* EZRadio driver init data and handler */
  EZRADIODRV_HandleData_t appRadioInitData = EZRADIODRV_INIT_DEFAULT;
  EZRADIODRV_Handle_t appRadioHandle = &appRadioInitData;

  /* Chip errata */
  CHIP_Init();
  CMU_ClockSelectSet(cmuClock_LFA, cmuSelect_LFRCO);

  /* Setup GPIO for pushbuttons. */
  GpioSetup();

  /* Set RTC to generate interrupt. */
  RTCDRV_Init();
  if (ECODE_EMDRV_RTCDRV_OK !=
      RTCDRV_AllocateTimer( &rtcTickTimer) )
  {
    while (1);
  }
  if (ECODE_EMDRV_RTCDRV_OK !=
      RTCDRV_StartTimer(rtcTickTimer, rtcdrvTimerTypePeriodic, APP_RTC_TIMEOUT_MS,
                        (RTCDRV_Callback_t)RTC_App_IRQHandler, NULL ) )
  {
    while (1);
  }

#if ( defined EZRADIO_PLUGIN_TRANSMIT )
  /* Configure packet transmitted callback. */
  appRadioInitData.packetTx.userCallback = &appPacketTransmittedCallback;
#endif

/* Initialize EZRadio device. */
  ezradioInit( appRadioHandle );  		<------ i want this ---	|
 									|
  while (1)								|
  {									|
          if(rtcTick)           // 30 seconds wake-up			|
          {								|
            rtcTick = false;						|
									|
          // Check Reed Status						|
           if (Reed_Value != GPIO_PinInGet(gpioPortF, 3) )		|
           {    Reed_Value = GPIO_PinInGet(gpioPortF, 3);		|
									|
							<----in here --	|
                // Run radio plug-in manager

                   ezradioPluginManager( appRadioHandle );

                // Add data to be sent to the packet
                ..
                ..
                // Transmit packet

                ezradioStartTransmitDefault( appRadioHandle, radioTxPkt );              
           }

           EMU_EnterEM2(false);
       }
  }
}

 

Posts: 91
Registered: ‎12-02-2016

Re: EZR32LG - deactivate EZRadio without reset

Hi,
There're few ways to let radio enter into low power mode.
1.
Pull up radio's SDN pin and keep it high before and after mcu enters into sleep mode.  After mcu wakes up,  call ezradioInit() again before operating the radio part.

2.
Call ezradio_change_state(EZRADIO_CMD_CHANGE_STATE_ARG_NEXT_STATE1_NEW_STATE_ENUM_SLEEP) to let radio enter into sleep or standby mode before mcu enters into sleep mode.
After mcu wakes up, call ezradio_change_state(EZRADIO_CMD_CHANGE_STATE_ARG_NEXT_STATE1_NEW_STATE_ENUM_READY) to let radio wake up first, then operate the radio to transmit or receive data.


Regards,
Yongsheng