Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

XMC™ Forum Discussions

Not applicable
Hi all,

I am working with an RTC module on an XMC4700 board. The problem is that the seconds counter seems to increment more than once per second, although the prescaler value is set to 0x7FFF. When I step into individual assembly instructions in Debug mode, the seconds register seems to increment every other istruction, sometimes even once per instruction primitive (ldr, etc,). Now, the weird part is that the timekeeping seems to be correct - whenever I display the register values obtained with XMC_RTC_GetTimeStdFormat();, on a hyperterminal via UART, the 'seconds' value seems to get incremented every second - I left the terminal running in the background and even after half an hour the RTC shows the correct time. However, interrupts that are handled by SCU_0_IRQHandler (<-- I hope this is not the mistake) seem to trigger more than once per second as each interrupt routine also clears the hyperterminal and it is indeed refreshed at a very fast speed - such that I can barely see some values.
0 Likes
4 Replies
Travis
Employee
Employee
First like received
agrus wrote:
Hi all,

I am working with an RTC module on an XMC4700 board. The problem is that the seconds counter seems to increment more than once per second, although the prescaler value is set to 0x7FFF. When I step into individual assembly instructions in Debug mode, the seconds register seems to increment every other istruction, sometimes even once per instruction primitive (ldr, etc,). Now, the weird part is that the timekeeping seems to be correct - whenever I display the register values obtained with XMC_RTC_GetTimeStdFormat();, on a hyperterminal via UART, the 'seconds' value seems to get incremented every second - I left the terminal running in the background and even after half an hour the RTC shows the correct time. However, interrupts that are handled by SCU_0_IRQHandler (<-- I hope this is not the mistake) seem to trigger more than once per second as each interrupt routine also clears the hyperterminal and it is indeed refreshed at a very fast speed - such that I can barely see some values.

Unfortunately, I haven't figured out if I can delete posts on this forum or not - but I found the issue. The interrupt flag is not cleared automatically when an interrupt handler is asserted - thus, an interrupt handler needs to clear the flag in order to quit the interrupt. It's a silly mistake on my end that took more time to figure out than it ever should have. Thank you for checking this post.



Hi,

FYI that interrupt flag needs to be cleared upon entry into the Interrupt sub routine.

I shall have a try of this RTC on XMC4800.
0 Likes
Travis
Employee
Employee
First like received
Hi agrus,

I had tested the XMC4800 which is almost similar as the XMC4700 device. Everything seems to be working good, the seconds counter seems to be counting good via the debugger and interrupt for both periodic and alarm events are working good too.

Attached is the example of XMC4800 using RTC. What I can suggest is that

1. Recreate a DAVE4 project with XMC4700
2. Copy the files main.c, RTC.c, SCU.c, XMC48_INIT.h, XMC48_IO.h and XMC48_IRQ.h into your XMC4700 project.
3. Make the necessary modification from XMC4800 to XMC4700.
4. Compile and Run the project
5. Set break point at RTC interrupt.
0 Likes
Travis
Employee
Employee
First like received
With regards to this behaviour "RTC interrupts are generated more than once per second" please check the SCU_SRMSK to ensure that you do not have other interrupts also as the Real time clock, Watch dog timer etc shares the same interrupt node.

1778.attach
0 Likes
Not applicable
Hi Travis,

Thank you for the concise and thorough reply - indeed, the problem was that I forgot to clear the interrupt flag, hence once a trigger has been set once, it has never been reset and interrupt kept triggering as if it was in a while() loop. The RTC module seems to be working very.

Cheers,
Andrey
0 Likes