Navigation bar
  Start Previous page
 70 of 206 
Next page End  

ZBasic Language Reference
62
ZX Microcontroller Family
3.7 Timers
The ZX series CPUs incorporate several timers, the actual number depending on the underlying CPU. 
On all ZX models, Timer0 and Timer2 are 8-bit timers while the remaining timers are 16-bit.   The table
below summarizes timer usage.
Timer Usage by CPU Type
Underlying CPU
RTC
I/O 
Serial
PWM 16-bit
InputCapture
OutputCapture
mega32, mega644,
mega644P, mega328P
Timer0
Timer1
Timer2
Timer1
Timer1
Timer1
mega1284P, mega128
Timer0
Timer3
Timer2
Timer1
Timer3
Timer1
Timer3
Timer1
Timer3
mega1281
Timer2
Timer4
Timer0
Timer1
Timer3
Timer1
Timer3
Timer1
Timer3
mega1280
Timer2
Timer4
Timer0
Timer1
Timer3
Timer4
Timer5
Timer1
Timer3
Timer4
Timer5
Timer1
Timer3
Timer4
Timer5
xmega32A4
TimerC1 TimerE0 TimerD1
TimerC0
TimerD0
TimerD1
TimerE0
TimerC0
TimerD0
TimerD1
TimerE0
TimerC0
TimerD0
TimerD1
TimerE0
xmega128A1
TimerC1 TimerF1 TimerD1
TimerC0
TimerD0
TimerD1
TimerE0
TimerE1
TimerF0
TimerF1
TimerC0
TimerD0
TimerD1
TimerE0
TimerE1
TimerF0
TimerF1
TimerC0
TimerD0
TimerD1
TimerE0
TimerE1
TimerF0
TimerF1
The RTC Timer is used to generate interrupts to manage the real time clock (RTC).  The I/O Timer is
used for several I/O functions that require accurate timing.  The Serial Timer is used to implement the
“software UART” for the serial channels Com3 to Com6 and, alternately on xmega-based devices, 8-bit
PWM generation.  When a specific timer is not being used by the system, you are free to use that timer in
your program as you wish.  To do so, you’ll have to read the Atmel datasheet for the underlying
microcontroller to determine how to program the timers and then use the built-in registers to read and
write the timer registers.  Further discussion of that topic is beyond the scope of this document.
3.8 Built-in Variables
The set of pre-defined registers comprises two sub-groups: actual CPU registers and control program
variables.  All of these built-in variables must be referenced using the Register prefix or within a With
Register compound statement.
Example
Dim tick as Long
tick = Register.RTCTick
In addition to the particular registers available for each underlying processor, three special register
variables are provided that correspond the PORT, PIN and DDR registers associated with a particular I/O
pin.  The form of these three special register functions is: Register.Port(<pin>),
Register.Pin(<pin>) and Register.DDR(<pin>), respectively.  In all three cases, the property
.DataAddress may be appended to get the address of the register associated with the specified pin.
Previous page Top Next page