10
INT0
Timer0_CompB
INT0
Timer2_CompB
INT0
Timer2_CompB
Timer1_CompB
Timer1_CompB
Timer1_CompC
Timer3_CompB
Timer1_CompB
Timer1_CompC
Timer3_CompB
Timer4_CompB
Timer5_CompB
INT0
INT1
INT2
PCINT0
PCINT1
PCINT2
PCINT3
Analog_Comp
INT0
INT1
INT2
INT3
INT4
INT5
INT6
INT7
PCINT0
PCINT1
PCINT2
Analog_Comp
INT0
INT1
INT2
INT3
INT4
INT5
INT6
INT7
PCINT0
PCINT1
PCINT2
Analog_Comp
Timers
ZX devices have three or more timers, depending on the underlying CPU type, that are used for various
purposes. One of the timers is used to implement the real time clock (RTC), another is used for the
software-based serial ports and a third timer is used to provide the precise timing required for certain I/O
routines. The specific timer that is used for a particular function varies depending on the underlying CPU
type as shown in the table below.
Underlying CPU
RTC
I/O
Serial
mega32
Timer0
Timer1
Timer2
Timer1
Timer1
Timer1
mega644
Timer0
Timer1
Timer2
Timer1
Timer1
Timer1
mega644P
Timer0
Timer1
Timer2
Timer1
Timer1
Timer1
mega128
Timer0
Timer1
Timer2
Timer1/3
Timer1/3
Timer1/3
mega1281
Timer2
Timer4
Timer0
Timer1/3
Timer1/3
Timer1/3
mega1280
Timer2
Timer4
Timer0
Timer1/3/4/5 Timer1/3/4/5 Timer1/3/4/5
The RTC Timer is programmed to generate an interrupt that is used to update the RTC and to trigger task
switching. Because its role is so central, the RTC Timer cannot be used for any other purpose. The I/O
Timer is used by several I/O related routines as explained in more detail below. The Serial Timer is used
to generate interrupts to implement the timing required for serial channels Com3 to Com6. If none of the
channels 3-6 is open, the Serial Port Timer can be used for other purposes in your program. Timers are
also used for some specialized I/O functions as indicated in the table above.
For each timer, there exists a built-in variable that indicates when the timer is in use. For example,
Register.Timer0Busy is a Boolean value that indicates when Timer0 is in use. Prior to using a timer,
the system checks the value of this variable to see if it is already being used. If it is not in use, the system
sets the flag to True and then proceeds to use the timer. When it is finished using the timer, the system
sets the busy flag to False. Your program may do the same by passing the Register variable as a