cancel
Showing results for 
Search instead for 
Did you mean: 

RTC interrupts

nanuradha
Associate II
Posted on February 14, 2007 at 16:18

RTC interrupts

2 REPLIES 2
nanuradha
Associate II
Posted on May 17, 2011 at 09:36

Hi all,

Have any bode worked on RTC interrupts? I've a problem with the periodic interrupt. It is getting executed only once. When crosschecking in the debug mode, i noticed that even when the flag PISF is set, ISR is not getting executed from the second time onwards. I've even tried reinitializing the interrupt but it also is not working. My code with reinitializing the interrupt is:

#include

GPIO_InitTypeDef GPIO_InitStructure;

void SCU_Configuration(void);

void GPIO_Configuration(void);

void VIC_Configuration(void);

void RTC_Configuration(void);

extern u8 k;

void main()

{

u8 i=0x0f;

#ifdef DEBUG

debug();

#endif

SCU_Configuration();

GPIO_Configuration();

RTC_Configuration();

VIC_Configuration();

k=0;

while(1)

{

if (k==1)

{

k=0;

i=~i;

RTC_ITConfig(RTC_IT_Per, DISABLE);

RTC_ITConfig(RTC_IT_Per, ENABLE);

RTC_PeriodicIntConfig(RTC_Per_2Hz);

RTC_ClearFlag(RTC_FLAG_Per);

}

GPIO_Write (GPIO7,i);

}

}

/********************************Subroutines******************************/

void VIC_Configuration(void)

{

VIC_DeInit();

VIC_Config(RTC_ITLine, VIC_IRQ, 0);

VIC_ITCmd(RTC_ITLine, ENABLE);

}

void SCU_Configuration(void)

{

SCU_APBPeriphClockConfig(__GPIO7, ENABLE);

SCU_AHBPeriphClockConfig(__VIC,ENABLE);

SCU_APBPeriphClockConfig(__RTC, ENABLE);

SCU_APBPeriphReset(__RTC,DISABLE); /*RTC out of RESET state*/

}

void RTC_Configuration()

{

RTC_TIME time;

RTC_DATE date;

RTC_DeInit();

/************** RTC Time setting*******************/

date.day = 7 ; /* set day */

date.weekday = 1; /* set weekday */

date.month = 1; /* set month */

date.year = 7; /* set year */

date.century = 20; /* set century */

time.hours = 11; /* set hours */

time.minutes = 32; /* set minutes */

time.seconds = 30; /* set seconds */

time.milliseconds = 0; /* set milliseconds */

/*set time & date*/

RTC_SetDate(date); /* set date in RTC */

RTC_SetTime(time); /* set time in RTC registers */

/***************** RTC Periodic Interrupt Settings***************/

RTC_ITConfig(RTC_IT_Per, ENABLE);

RTC_ClearFlag(RTC_FLAG_Per);

RTC_PeriodicIntConfig(RTC_Per_2Hz);

}

void GPIO_Configuration(void)

{

GPIO_DeInit(GPIO7); /*Gonfigure LEDS*/

GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput;

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;

GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ;

GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable;

GPIO_InitStructure.GPIO_Alternate = GPIO_OutputAlt1 ;

GPIO_Init (GPIO7, &GPIO_InitStructure);

}

The ISR is:

u8 k;

void RTC_IRQHandler(void)

{

k=1;

}

Please give me a solution for this as quickly as possible. it is very urgently required.

Regards,

Neelima.

alandras
Associate II
Posted on May 17, 2011 at 09:36

Hi,

What is the revision of your silicon? There is an errata about RTC:

www.st.com/stonline/products/literature/es/12280.pdf

Quote:

RTC periodic interrupt

Description of limitation for all silicon revisions

When reading the Status register for the Periodic Interrupt flag, the CPU may occasionally

miss the flag's set status.

Workaround

Do not poll the RTC interrupt flag. Always use the RTC interrupt signal to the VIC to cause a

standard interrupt. This will not be fixed in future silicon revisions.

This is for all devices, but I have one with date code 619 and strangely I can't clear RTC periodic interrupt and my ISR is fired like a level sensitive one. For 2 Hz period 500 ~ 500 ms. Half period nothing, half period all the time. See my log file.

What is happening is that the PISF (Periodic Interrupt Flag) is cleared after the first read of RTC_SR (RTC Status Register ) but the VIC1_ISR (IRQ Status Register ) still shows 0x0100.

I'm afraid the errata is not complete. Is there a workaround for this?

I tried to disable and re-enable during the ISR both the Periodic-Interrupt and the VIC, reading the RTC_SR between but the IRQ is triggered for a half period anyway

I read this recent post too:

http://mcu.st.com/mcu/modules.php?mop=modload&name=Splatt_Forums&file=viewtopic&topic=4868&forum=21

thanks in advance,

Andras