Forum : ARM
Original Post
Post Information | Post |
---|---|
November 25, 2008 - 5:27am
|
Hi, I am using the RTC on the stm32 to schedule events but whenever the interrupt fires it corrupts my global variables. e.g. I have a global pointer that points to the same place as SPI1 for one of my drivers. If i print it's address out the uart it shows as 0x4001300 but after an rtc alarm interrupt it prints out as something else (e.g. 0x4001a7f6, 0x4001bfb...). This then causes a hardware fault interrupt the next time it's used. Statically allocated ints and my uart buffer are also affected and both normal and volatile ones. (also the 'volatile globals' and 'volatile pointers' compiler options do not work). My uart receive interrupt doesn't cause any similar problems and I am very confused, does anyone have any ideas? void RTC_IRQHandler(void) { u32 temp; if(RTC_GetITStatus(RTC_IT_ALR)) { RTC_WaitForLastTask(); temp = RTC_GetCounter(); RTC_WaitForLastTask(); RTC_SetAlarm(temp + BKP_ReadBackupRegister(BKP_DR4) - 1); RTC_WaitForLastTask(); RTC_ClearITPendingBit(RTC_IT_ALR); ReadPending = SET; } else { printf("\r\n+ERROR: Invalid RTC interrupt.\r\n"); } } |
1. Check the stack location (I had recently a similar protblem and I realized that the stack runs over my global variables because of a mistake in the LD file).
2. To find out the source of my problem, I used under RIDE a 'write breakpoint' (push on the small 'w' button' in a dump memory view after selecting the address).
Thanks for your suggestions. It seems 2. has given me the answer. Looks like i was writing passed the end of some arrays (how embarrassing, guess i'd need x-ray glasses to see the 'index out of bounds'/'segmentation fault').
I did find that the write breakpoint could be set in the 'Memory View', but couldn't be set in the 'Memory View (32-bit)'.