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
  • hello Aryan, thank you for your quick response.

    so yes the POWER_CLOCK_IRQn is enabled using NVIC.

    I'm using external 16MHz crystal oscillator for HFCLK and external 32,768KHz crystal oscillator for LFCLK.

    Something I haven't anderstand in your code is why do you makewhile(NRF_CLOCK->EVENTS_HFCLKSTARTED != 1);in the rtc_IRQ ? this is to wait the HFCLK crystal to be ready, right ?

    because I make my program to sleep during the ramping up of the HF crystal.

    in the rtc_IRQ I just want to start the HF crystal but I don't want to wait until it is ready. After HF crystal is started, I want to sleep and to be waking up when the HF crystal is ready. So to be waking up by the HFclock_IRQ.

    RTC_irq job's to start HFclock and HFclk_irq job's to do something where the HFcrystal is available like sending data by radio.

    I make a little diagram to tell you more explicitly what I would like to do. (the HFclk_irq is a little bit longer than RTC because we send a data)

    RTC_irq                                                 *
    HFclk_irq                                                               ***
    
    
    Awake                                                   *               ***
    Sleeping             *********************************** ***************   ****************
    
    
    HFcrystal_ready                                                         ***
    Hfcrystal_ramping_up                                     ***************
    LFcrystal_ready      ********************************************************************** ---> [t]
    

    THANKS YOU VERY MUCH FOR YOUR ANSWERS, YOU ARE A VERY GOOD TEAM =)

  • Hi bibi, Can you please update this thread with your status

Reply Children
No Data
Related