RTC data sheet global variable caution

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

cross mob
alfi_297226
Level 1
Level 1
5 questions asked Welcome! 5 replies posted

Why does the RTC data sheet caution "You should disable the component’s interrupts while calling functions that read or modify global variables."

A sentence or two of why this caution is mentioned in the RTC datasheet would seem to be appropriate. Datasheets for other components, such as the Interrupt component  make no similar mention.

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Accessing data which might get changed by an interrupt should always be done with interrup disabled.

Since the access might not be atomic the interrupt might occur just within the data read, giving a time of 23:59 (before int) and a date of one day past (after the interrupt). You might use the CyEnterCriticalSection() and Cy_ExitCriticalSection() APIs (from System Reference Guide)

Bob

View solution in original post

0 Likes
1 Reply
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Accessing data which might get changed by an interrupt should always be done with interrup disabled.

Since the access might not be atomic the interrupt might occur just within the data read, giving a time of 23:59 (before int) and a date of one day past (after the interrupt). You might use the CyEnterCriticalSection() and Cy_ExitCriticalSection() APIs (from System Reference Guide)

Bob

0 Likes