![Rabbit Rabbit 4000 User Manual Download Page 145](http://html1.mh-extra.com/html/rabbit/rabbit-4000/rabbit-4000_user-manual_3116714145.webp)
135
16.3 Operation
16.3.1 Asynchronous Mode
The following steps explain how to set up Serial Ports A – D for asynchronous operation.
The serial ports can be used by polling the status byte, but their performance will be better
with an interrupt. These instructions also apply to the asynchronous operation of Serial
Ports E – F.
1. Write the interrupt vector for the interrupt service routine to the internal interrupt table.
2. Set up the desired transmit pin by writing to the appropriate parallel port function register
(PxFR) and alternate output register (PxALR or PxAHR).
3. Select the appropriate mode by writing to SxCR (receive input port and 7 or 8 bits).
Also select the interrupt priority.
4. Select additional options by writing to SxER (parity, RZI encoding, clock polarity, and
behavior during break).
5. Write the desired divider value to TATxR for the appropriate serial port, or else write a
divider value to the dedicated 15-bit divider in SxDLR and SxDHR. If the dedicated
divider is to be used, write a 1 to the most-significant bit of SxDHR to enable it.
A sample asynchronous serial interrupt handler is shown below for Serial Port A.
async_sera_isr::
push af ; save used registers
ioi ld a, (SASR) ; get status
bit a,7 ; check if byte ready in RX buffer
push af ; save status for next check
jr z, check_for_tx
rx_ready:
ioi ld a, (SADR) ; read byte and clear interrupt
; do something with byte here
check_for_tx:
pop af
bit a,3 ; check if TX buffer was emptied
jr nz, done
; get next byte to be transmitted into A here
ioi ld (SADR), a ; load next byte into TX buffer and clear interrupt
done:
pop af ; restore used registers
ipres
ret
To transmit with an address (1) bit appended, write the data to SxAR instead of SxDR; to
append a long stop (0) bit write to SxLR instead.
Summary of Contents for Rabbit 4000
Page 1: ...Rabbit 4000 Microprocessor User s Manual 019 0152 070720 H...
Page 18: ...8 Rabbit 4000 Microprocessor User s Manual...
Page 40: ...30 Rabbit 4000 Microprocessor User s Manual...
Page 74: ...64 Rabbit 4000 Microprocessor User s Manual...
Page 82: ...72 Rabbit 4000 Microprocessor User s Manual...
Page 86: ...76 Rabbit 4000 Microprocessor User s Manual...
Page 96: ...86 Rabbit 4000 Microprocessor User s Manual...
Page 182: ...172 Rabbit 4000 Microprocessor User s Manual...
Page 240: ...230 Rabbit 4000 Microprocessor User s Manual...
Page 248: ...238 Rabbit 4000 Microprocessor User s Manual...
Page 256: ...246 Rabbit 4000 Microprocessor User s Manual...
Page 310: ...300 Rabbit 4000 Microprocessor User s Manual...
Page 330: ...320 Rabbit 4000 Microprocessor User s Manual...
Page 348: ...338 Rabbit 4000 Microprocessor User s Manual...