Download Rabbit 3000 Microprocessor User`s Manual
Transcript
17.3 Operation 17.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 (PCFR or PDFR). 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. A sample asynchronous serial interrupt handler is shown below for Serial Port A. async_sera_isr:: push af ioi ld a, (SASR) bit 7,a push af jr z, check_for_tx rx_ready: ioi ld a, (SADR) ; ; ; ; save used registers get status check if byte ready in RX buffer save status for next check ; read byte and clear interrupt ; do something with byte here check_for_tx: pop af bit 3,a jr nz, done ; check if TX buffer was emptied ; get next byte to be transmitted into A here ioi ld (SADR), a done: pop af ipres ret ; load next byte into TX buffer and clear interrupt ; restore used registers 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. Chapter 17 Serial Ports A – D 137