Page 1 of 1

STM32F4 RTC interrupt every second

Posted: Sun Feb 08, 2015 4:49 pm
by pinnchus
Hello everyone,
I need help to generate an interrupt from RTC every second on a board using STM32F4xx. I tried several alternatives, and have failed to make it work, does anyone could help me with an example?

Thanks,
Pinnchus

Re: STM32F4 RTC interrupt every second

Posted: Sun Feb 08, 2015 5:07 pm
by Giovanni
Hi,

Must it be necessarily from the RTC? you can use a virtual timer for that. Note that RTC interrupts are routed through EXTI on the F4, you need to use the EXT driver for that (see the EXT demo).

Giovanni

Re: STM32F4 RTC interrupt every second

Posted: Sun Feb 08, 2015 5:13 pm
by Giovanni
Hi,

Must it be necessarily from the RTC? you could use a virtual timer for periodic interrupts.

About the RTC, its interrupts are routed through EXTI on the F4, you need to use the EXT driver for that (see the EXT demo). The EXT driver invokes a callback when an event is registered on one of its inputs.

Giovanni

Re: STM32F4 RTC interrupt every second

Posted: Tue Feb 10, 2015 11:18 pm
by pinnchus
Giovanni, Thanks for your fast answer.

Follow the example i did this add to the code (at following) and put the

Code: Select all

extStart(&EXTD1, &extcfg);
in the main() rutine. But does not work, am I doing somthing wrong? :oops:

Thanks for you help,
Pinnchus


Code: Select all

static const EXTConfig extcfg = {
  {
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_DISABLED, NULL},
    {EXT_CH_MODE_RISING_EDGE | EXT_CH_MODE_AUTOSTART | 22, extcb1}
  }
};


Code: Select all

static void extcb1(EXTDriver *extp, expchannel_t channel) {
 
  (void)extp;
  (void)channel;
  chSysLockFromIsr();
  OneHz();
  chSysUnlockFromIsr();
}

Re: STM32F4 RTC interrupt every second

Posted: Tue Feb 10, 2015 11:44 pm
by pinnchus
Thanks....

Solved using this code as example:

https://github.com/Tecnologic/ThunderCryer/blob/master/Clock/CRTCHandler.cpp

Regards,
Pinnchus

Re: STM32F4 RTC interrupt every second

Posted: Wed Feb 11, 2015 9:14 am
by Giovanni
The problem was that |22.

Giovanni

Re: STM32F4 RTC interrupt every second

Posted: Sat Oct 06, 2018 1:23 pm
by phoenix2000
Hi Giovanni
I want to show the clock and my board is stm32f429i discovery.
Is it better to use a virtual timer and in its body read time and date of rtc instead of setting up an interrupt of rtc?
PS: As much as I understand from the datasheet for doing this, the best interrupt is wakeup interrupt which we can get interrupt in every second forever.

Re: STM32F4 RTC interrupt every second

Posted: Sat Oct 06, 2018 2:17 pm
by Giovanni
Hi,

You may use a virtual timer or a dedicated thread for this kind of things, no need to use interrupts at all.

Giovanni