Rtc Interrupt for 5 sec

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Rtc Interrupt for 5 sec

2,529 Views
intern_praveena
Contributor II

i am using FS32K144Q100 in which i have done code for led blink using RTC but i want 5 sec delay with interrupt .how to do???here is my code..

9 Replies

2,309 Views
intern_praveena
Contributor II

please explain in my code

0 Kudos
Reply

2,309 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Something like this?

void alarmISR(void)
{
  sec_counter++;

  if(sec_counter > 5)
  {
    /* Toggle the alarm led */
    PINS_DRV_TogglePins(PTD, (1 << 15));
    sec_counter = 0;
  }
}‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

2,309 Views
intern_praveena
Contributor II

void alarmISR(void)
{
/* Toggle the alarm led */
PINS_DRV_TogglePins(PTD, (1 << 15));

// wait for conditions
}

From the above code , led is toggle and comes out for every 1 sec , so what i want is that there should be any conditions to  wait for 5 sec and after that 6th sec it should toggle next like that.can u understand????

0 Kudos
Reply

2,309 Views
danielmartynek
NXP TechSupport
NXP TechSupport

I would use a SW counter (global variable) in the ISR and let it count (increment every second) up to 5.

Once it equals 5, I would clear the counter and toggle the LED. 

But that's up to you.   

BR, Daniel

0 Kudos
Reply

2,309 Views
intern_praveena
Contributor II

every 1 sec alarmISR is calling in that i want 5 sec delay . So what logic i have to use inside the alarmISR function. here is my function,

void alarmISR(void)
{
/* Toggle the alarm led */
PINS_DRV_TogglePins(PTD, (1 << 15));

}

0 Kudos
Reply

2,309 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi Praveena,

If you want the alarm interrupt to be called every 5s, just increase RTC Time Alarm Register by 5 in the Alarm ISR.

void RTC_IRQHandler(void)
{
  RTC->TAR += 5; // Writing to the TAR clears the SR[TAF] Time Alarm Flag.
                 // Next alarm in 5s
}

BR, Daniel

0 Kudos
Reply

2,308 Views
intern_praveena
Contributor II

I alrdy used alarm_interrupt its working . i want how to make that alarm delay for 5 sec using second interrupt.

0 Kudos
Reply

2,308 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hello Praveena,

Please have a look at Section 48.4.7 Interrupt, S32K1xx RM rev.9

pastedImage_1.png

As you can see, the frequency of the second interrupt is configurable but it can't trigger every 5s.

pastedImage_2.png

Regards,

Daniel

0 Kudos
Reply

2,308 Views
danielmartynek
NXP TechSupport
NXP TechSupport

Hi,

The RTC module has two interrupts: Second interrupt and alarm interrupt.

The alarm interrupt allow the RTC to generate an interrupt at a predefined time.

Please refer to the rtc_alarm_s32k144 SDK RTM 3.0.0 example that is available in the S32DS.

Regards,

Daniel

0 Kudos
Reply