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

interrupt on HFCLKSTARTED problem

Hi, I have a problem with the HFCLKSTARTED interrupt.

I can't have it. (I'm a little bit pressed with time I have to send a document in 2 days, so if you can quick respond to my 2 simple questionS first, and maybe later have a look for the rest you will be very nice :-))

MY SIMPLE QUESTION 1 : can whe stop the HFCLK and directly going to sleep calling __wfi() ?

doing that

nRF_POWER->TASKS_LOWPWR = 1UL;    // instruction 1)
NRF_CLOCK->TASKS_HFCLKSTOP = 1;   // instruction 2)
__WFI();                          // instruction 3)

MY SIMPLE QUESTION 2 : What's happening between the instruction 2 and 3 ??? is there the time for the RC to start to execute __WFI ?

I make a program who is in low power mode and sleep calling __wfi() with HFCLK stopped.

perriodicaly it wake up with the RTC. In the RTC_irq I start the HFCLK and to save power by go directly in low power mode and sleep calling __wfi(), waiting the HFCLK

and after I normaly get the HFCLKSTARTED interrupt where I can send a data by bluethoot. But I never get it. and with the debuger I'm get blocked in the "arm_startup_nrf51.s(startup)" file.

My program:

int main()
{
   initALL();
   while(true)
   {
      NRF_POWER->TASKS_LOWPWR = 1UL;
	  if(HF_Clk_Stay_On_To_Sleep == false) NRF_CLOCK->TASKS_HFCLKSTOP = 1;
      __WFI();
   }
 }

rtc_IRQ(void)
{
	 NRF_CLOCK->TASKS_HFCLKSTART = 1;          // start HFclock
     NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;       // clear clock event
	 HF_Clk_Stay_On_To_Sleep = true;
     NRF_RTC0->TASKS_CLEAR = 1UL;              // clear RTC event
     NRF_RTC0->EVENTS_COMPARE[0] = 0;          // clear RTC event
 }

HFclock_IRQ(void)
{
	HF_Clk_Stay_On_To_Sleep = false;
	Radio_Send_Data();     // send a data by radio
}

Is there something I make wrong ? if you have an idee tell me. Thank you very much for your time.

Parents
  • Hi bibi, I need to ask you if you are using external crystal oscillator? You cannot control HFCLK RC oscillator. The system manages it automatically.

    NVIC_EnableIRQ(POWER_CLOCK_IRQn); // do this in main
    
    rtc_IRQ(void)
    {
         NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;       // clear clock event
         NRF_CLOCK->TASKS_HFCLKSTART = 1;          // start HFclock
    
         HF_Clk_Stay_On_To_Sleep = true;
         NRF_RTC0->TASKS_CLEAR = 1UL;              // clear RTC event
         NRF_RTC0->EVENTS_COMPARE[0] = 0;          // clear RTC event
     }
    
    HFclock_IRQ(void)
    {
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;       // clear clock event
        HF_Clk_Stay_On_To_Sleep = false;
        Radio_Send_Data();     // send a data by radio
    }
    

    After __wfe() the RC clock will be automatically shutdown if no other peripherals require HF RC.

    I think the problem that you face is that you are not clearing the event in HFclock interrupt. The modified code above work. Have you enabled the interrupt by the way using NVIC_EnableIRQ(POWER_CLOCK_IRQn);

Reply
  • Hi bibi, I need to ask you if you are using external crystal oscillator? You cannot control HFCLK RC oscillator. The system manages it automatically.

    NVIC_EnableIRQ(POWER_CLOCK_IRQn); // do this in main
    
    rtc_IRQ(void)
    {
         NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;       // clear clock event
         NRF_CLOCK->TASKS_HFCLKSTART = 1;          // start HFclock
    
         HF_Clk_Stay_On_To_Sleep = true;
         NRF_RTC0->TASKS_CLEAR = 1UL;              // clear RTC event
         NRF_RTC0->EVENTS_COMPARE[0] = 0;          // clear RTC event
     }
    
    HFclock_IRQ(void)
    {
        NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;       // clear clock event
        HF_Clk_Stay_On_To_Sleep = false;
        Radio_Send_Data();     // send a data by radio
    }
    

    After __wfe() the RC clock will be automatically shutdown if no other peripherals require HF RC.

    I think the problem that you face is that you are not clearing the event in HFclock interrupt. The modified code above work. Have you enabled the interrupt by the way using NVIC_EnableIRQ(POWER_CLOCK_IRQn);

Children
No Data
Related