20 of 307
ZBasic System Library 10 ZX Microcontroller Family USART1_RX USART1_TX USART1_UDRE Timer2_CompA Timer2_CompA Timer2_CompA Timer0_CompA Timer0_CompA USART1_RX USART1_TX USART1_UDRE USART1_RX USART1_TX USART1_UDRE USART1_RX USART1_TX USART1_UDRE USART2_RX USART2_TX USART2_UDRE USART3_RX USART3_TX USART3_UDRE OpenX10() INT0 Timer0_CompB Timer0_CompB INT0 n/a INT0 Timer2_CompB Timer2_CompB INT0 OutputCapture() Timer1_CompB Timer1_CompB Timer1_CompB Timer1_CompB Timer1_CompB Timer1_CompC Timer1_CompC Timer1_CompC Timer3_CompB Timer3_CompB Timer3_CompB Timer4_CompB Timer5_CompB WaitForInterrupt() INT0 INT1 INT2 PCINT0 PCINT1 PCINT2 PCINT3 Analog_Comp INT0 INT1 PCINT0 PCINT1 PCINT2 Analog_Comp INT0 INT1 INT2 INT3 INT4 INT5 INT6 INT7 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. Timer Usage by CPU Type Underlying CPU RTC I/O Serial 16-bit PWM InputCapture OutputCapture mega32 Timer0 Timer1 Timer2 Timer1 Timer1 Timer1 mega644 Timer0 Timer1 Timer2 Timer1 Timer1 Timer1 mega644P Timer0 Timer1 Timer2 Timer1 Timer1 Timer1 mega328P 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. The Serial timer is also used for 8-bit PWM generation. Consequently, use of 8-bit PWM and use of Com3 to Com6 are mutually exclusive.