STM32F4 RTC interrupt every second

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

Moderators: barthess, RoccoMarco

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

STM32F4 RTC interrupt every second

Postby pinnchus » Sun Feb 08, 2015 4:49 pm

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: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: STM32F4 RTC interrupt every second

Postby Giovanni » Sun Feb 08, 2015 5:07 pm

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: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: STM32F4 RTC interrupt every second

Postby Giovanni » Sun Feb 08, 2015 5:13 pm

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

Postby pinnchus » Tue Feb 10, 2015 11:18 pm

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

Postby pinnchus » Tue Feb 10, 2015 11:44 pm

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: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: STM32F4 RTC interrupt every second

Postby Giovanni » Wed Feb 11, 2015 9:14 am

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

Postby phoenix2000 » Sat Oct 06, 2018 1:23 pm

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: 11306
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 412 times
Been thanked: 342 times
Contact:

Re: STM32F4 RTC interrupt every second

Postby Giovanni » Sat Oct 06, 2018 2:17 pm

Hi,

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

Giovanni


Return to “STM32 Support”

Who is online

Users browsing this forum: No registered users and 7 guests