STM32F4 RTC interrupt every second

ChibiOS public support forum for topics related to the STMicroelectronics STM32 family of micro-controllers.

Moderator: RoccoMarco

Post Reply
pinnchus
Posts: 3
Joined: Sun Feb 08, 2015 4:45 pm

STM32F4 RTC interrupt every second

Post 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
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 RTC interrupt every second

Post 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
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 RTC interrupt every second

Post 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
pinnchus
Posts: 3
Joined: Sun Feb 08, 2015 4:45 pm

Re: STM32F4 RTC interrupt every second

Post 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();
}
pinnchus
Posts: 3
Joined: Sun Feb 08, 2015 4:45 pm

Re: STM32F4 RTC interrupt every second

Post by pinnchus »

Thanks....

Solved using this code as example:

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

Regards,
Pinnchus
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 RTC interrupt every second

Post by Giovanni »

The problem was that |22.

Giovanni
phoenix2000
Posts: 2
Joined: Sat Mar 03, 2018 12:27 pm
Has thanked: 4 times

Re: STM32F4 RTC interrupt every second

Post 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.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: STM32F4 RTC interrupt every second

Post 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
Post Reply