![]() ZBasic System Library
14
ZBasic Microcontrollers
RCTime()
TimerSpeed2¹
PlaySound()
PulseIn()
TimerSpeed2¹
PulseOut()
TimerSpeed2¹
Put1Wire()
Put1WireByte()
Put1WireData()
PWM()
PWM8()
Reset1Wire()
ShiftIn()
TimerSpeed1
ShiftInEx()
TimerSpeed1
ShiftOut()
TimerSpeed1
ShiftOutEx()
TimerSpeed1
SPICmd()²
TimerSpeed1
X10Cmd()
Notes:
1)
2)
The timer is used only for software based channels.
The table below shows the correspondence between the allowable values for the TimerSpeed registers
and the resulting clock frequency applied to the I/O Timer in terms of the CPU frequency. The divisor
specified is applied to the CPU clock frequency to yield the I/O Timer clock frequency. For compatibility
with BasicX (but only for ZX processors running at 14.7456MHz), some of the routines effectively divide
the timer frequency by 2 so that the time units associated with parameters or return values are preserved.
If you change the timer speed setting, the scale factor is still applied.
TimerSpeed Selector Values
TimerSpeed
Value
Frequency
ATtiny, ATmega
Frequency
ATxmega
0
0
0
1
F_CPU / 1
F_CPU / 1
2
F_CPU / 8
F_CPU / 2
3
F_CPU / 64
F_CPU / 4
4
F_CPU / 256
F_CPU / 8
5
F_CPU / 1024
F_CPU / 64
6
External T1
F_CPU / 256
7
External T2
F_CPU / 1024
8-15
n/a
Event 0-7
The default values of Register.TimerSpeed1 and Register.TimerSpeed2 are shown in the table
below.
Default TimerSpeed Values
CPU Family
TimerSpeed1
TimerSpeed2
ATmega, ATtiny
1
2
ATxmega
2
4
Note that setting the value of either of the timer speed registers other than by direct assignment using an
assignment statement will produce undefined results.
There are several important facts to keep in mind if you modify either of the timer speed values. Firstly,
the timer speed values are initialized by the system when it begins running and they are never modified
by the system thereafter. If you change a timer speed value, that value will be used by all of the related
System Library routines until you change it again. Secondly, the applicable TimerSpeed value is used
during the configuration and setup of each I/O function. If you change the TimerSpeed value after a
particular I/O function is configured, the change will not affect I/O functions configured before that change.
|