This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

How do you put the nrf51822 chip to sleep?

I am wondering how you put the nrf51822 chip to sleep. I've determined that the way to do this with the soft device is sd_app_event_wait() in the while loop. What about non-softdevice?

I am wanting to have it sleep until woken by interrupts, then sleep again. In another example, I found __wfi() used. Also, __WFI(). Neither seem to do anything, though.

Thanks!

Parents
  • Anders wrote

    "The event flag is set by a number of different things in the CPU including returning from an interrupt."

    Are you sure event flag is set after interrupt is done? In such case WFE is safe and race condition can't happen. Just to be sure I'm using SEV after flag was set, like this:

    void RTC1_IRQHandler(void)
    {
      /* Update compare counter */
    	if (NRF_RTC1->EVENTS_COMPARE[0] != 0)
      {
    		NRF_RTC1->EVENTS_COMPARE[0] = 0;
    		NRF_RTC1->TASKS_CLEAR = 1;  // Clear Counter		    
    		if(U32_delay_ms) U32_delay_ms--; // used in V_hw_delay_ms()
    		__SEV(); // to avoid race condition
      }
    }
    
Reply
  • Anders wrote

    "The event flag is set by a number of different things in the CPU including returning from an interrupt."

    Are you sure event flag is set after interrupt is done? In such case WFE is safe and race condition can't happen. Just to be sure I'm using SEV after flag was set, like this:

    void RTC1_IRQHandler(void)
    {
      /* Update compare counter */
    	if (NRF_RTC1->EVENTS_COMPARE[0] != 0)
      {
    		NRF_RTC1->EVENTS_COMPARE[0] = 0;
    		NRF_RTC1->TASKS_CLEAR = 1;  // Clear Counter		    
    		if(U32_delay_ms) U32_delay_ms--; // used in V_hw_delay_ms()
    		__SEV(); // to avoid race condition
      }
    }
    
Children
No Data
Related