Start Back Next End
  
ZBasic System Library
334
ZBasic Microcontrollers
UpdateRTC
Type
Subroutine
Invocation
UpdateRTC(fastTicks)
Parameter
Method
Type
Description
fastTicks
ByVal
int16
The number of fast ticks to add to the RTC.
Discussion
This subroutine can be used to update the RTC with the number of fast ticks missed during a long
operation performed with interrupts disabled.  In order to determine the number of fast ticks that are
missed, your code must periodically check the interrupt flag of the RTC timer and, if it is set, increment a
local counter value and then reset the interrupt flag.
Example
' This example is for ZX devices that use Timer0 for the RTC timer.
Atomic
Dim missedTicks as UnsignedInteger
Const TickFlag as Byte = &H02
missedTicks = 0
Do
' place code here that performs one iteration of a
' long process and eventually exits the loop
' check the RTC flag, reset it
If (CBool(Register.TIFR0 And TickFlag)) Then
missedTicks = missedTicks + 1
Register.TIFR0 = TickFlag
End If
Loop
Call UpdateRTC(missedTicks)
Call Yield()
End Atomic
Compatibility
This subroutine is not available if the RTC is not enabled in your application.
See Also
Previous page Top Next page