![]() ZBasic System Library
15
ZBasic Microcontrollers
Note, also, that values returned by some of the System Library routines are scaled based on the default
timer speed values. If you change the timer speed setting, youll have to apply an additional scale factor
in order to get the correct results. For example, if you set Register.TimerSpeed2 to 3 on an ATmega-
based device running at 14.7MHz and then call the subroutine PulseIn(), a pulse having a width of
100µS will return the value of approximately 12.5µS since the clock speed that you specified is 1/8 that of
the default. In order to get the correct pulse width, in seconds, you will have to multiply the value returned
by 8. Those return values that are not scaled to seconds represent a number of periods of the timer
frequency. So, for example, if you change Register.TimerSpeed1 to 2 on an ATmega-based device
running at 14.7MHz, the values returned by InputCapture() represent units of 542nS instead of the
default 67.8nS.
For those devices that support mapping of timer compare outputs to physical pins, the table below shows
the default mapping. You can specify a different mapping for your application by using the device
configuration parameter TimerOCPin. See the description of this device parameter in the ZBasic
Lanugage Reference Manual.
Default Output Compare Pin Mapping
Device
Timer Compare
Output
TOCCn
Pin
tiny828
OC0A
0
C.0
OC0B
1
C.1
OC1A
6
C.6
OC1B
7
C.7
tiny441, tiny841
OC0A
5
A.6
OC0B
4
A.5
OC1A
7
B.2
OC1B
6
A.7
OC2A
3
A.4
OC2B
2
A.3
The tables below give the set of valid 16-bit PWM channels, the associated timer, and the corresponding
output pin for each channel. See OpenPWM for the details of setting up a 16-bit PWM output.
16-bit PWM Timers, Channels and Pins for ZX Devices
ZX Device
Timer
Chan.
Pin
Chan.
Pin
Chan.
Pin
ZX-24, ZX-24a, ZX-24p, ZX-24n
Timer1
1
26, D.5
2
27, D.4
ZX-24e, ZX-24ae, ZX-24ne,
ZX-24pe, ZX-24nu, ZX-24pu
Timer1
1
15, D.5
2
16, D.4
ZX-40, ZX-40a, ZX-40p, ZX-40n
Timer1
1
19, D.5
2
18, D.4
ZX-44, ZX-44a, ZX-44p, ZX-44n
Timer1
1
14, D.5
2
13, D.4
ZX-24r, ZX-24s, ZX-24t
Timer1
Timer3
1
3
26, D.5
B.6
2
4
27, D.4
B.7
ZX-24ru, ZX-24su
Timer1
Timer3
1
3
15, D.5
22, B.6
2
4
16, D.4
21, B.7
ZX-40r, ZX-40s, ZX-40t
Timer1
Timer3
1
3
19, D.5
7, B.6
2
4
18, D.4
8, B.7
ZX-44r, ZX-44s, ZX-44t
Timer1
Timer3
1
3
14, D.5
2, B.6
2
4
13, D.4
3, B.7
ZX-328n, ZX-328l
Timer1
1
15, B.1
2
16, B.2
ZX-32n, ZX-32l
Timer1
1
13, B.1
2
14, B.2
ZX-328nu
Timer1
1
12, B.1
2
13, B.2
|