129
Figure 12-7 shows the timing relationship among perclk, the external serial clock, and data receive. Note that RxA is sampled by the rising edge of perclk.
Figure 12-7. Synchronous Serial Data Receive Timing with External Clock
When clocking the Rabbit externally, the maximum serial clock frequency is limited by
the amount of time required to synchronize the external clock with the Rabbit perclk. If
we sum the maximum number of perclk cycles required to perform clock synchroniza-
tion for each of the receive and transmit cases, then the fastest external serial clock fre-
quency would be limited to perclk/6.
12.7 Serial Port Software Suggestions
The receiver and transmitter share the same interrupt vector, but it is possible to make the
receive and transmit interrupt service routines (ISRs) separate by dispatching the interrupt
to either of two different routines. This is desirable to make the ISR less complex and to
reduce the interrupt off time. No interrupts will be lost since distinct interrupt flip-flops
exist for receive and transmit. The dispatcher can test the receiver data register full bit to
dispatch. If this bit is on, the interrupt is dispatched for receive, otherwise for transmit.
The receiver receives first consideration because it must be serviced attentively or data
could be lost.
The dispatcher might look as follows.
interrupt:
PUSH AF
; 10
IOI LD A,(SCSR)
; 7 get status register serial port C
OR A
; 2 test sign bit
JP M,receive
; 7 go service the receive interrupt
JP transmit
; 7 (41 clocks to here) go service transmit interrupt
The individual interrupts would assume that register AF has been saved and the status reg-
ister has been loaded into register A.
The interrupt service routines can, as a matter of good practice and obtaining optimum
performance, remove the cause of the interrupt and re-enable the interrupts as soon as pos-
sible. This keeps the interrupt latency down and allows the fastest transmission speed on
all serial ports.
All the serial ports will normally generate priority level 1 interrupts. In exceptional circum-
stances, one or more serial ports can be configured to use a higher priority interrupt. There is
Valid
perclk
CLKA
RxA
(Ext.)