Woody Home Page
Simple UART
Nov 19, 2007
Because of increasing interest to use AR1688 UART pins for non-standard VoIP applications, we added UART software support in current 0.25 test software.
The UART in AR1688 is the simplest, only a RX pin and a TX pin, no hardware flow control nor status pins. Hardware 8 level by 8 bits FIFO are used to buffer receiving and sending data. There is 0.16% hardware clock error with all baudrate because of PLL limitation.
UART software can be compiled using OEM_UART option. The 2 UART pins are already used in ADC keys (AR168F/AR168G/GF302/YWH201), 5x5 keys (GP1266) and 5x6 keys (AR168K), we need to disable all those keys when using UART.
The UART is currently configured as 19200bps baudrate, 8 bits data, 1 bit stop and none-parity. Can be configured up to 115200bps if necessary.
When receiving data, Z80 will be interrupted when receiving FIFO is half full, we will read all available data in a 255 bytes circle buffer and wait for main loop to handle the data. We avoid to be in UART interrupt routine as much as we can to prevent it slowing done DSP by blocking Z80 DSP interrupt.
When sending, no interrupt is used, we will put all sending data into another 255 bytes circle buffer and try to write TX FIFO until full whenever we can, both in sending data function and in main loop. We use 255 bytes sending buffer because we do not hope to poll until all data sent out, to avoid blocking main loop to handle other more critical tasks like RTP traffic.
There is no receiving or sending data error report to upper lever software, application software must handle data check and necessary re-transmission for reliable data exchange.
We implemented a "string" based UART communication example in uart.c, without any error check, using '\0' as separator for data groups over UART. To ensure data can be received as soon as sent, we actually added 4 extra '\0' in each sent string because the Z80 interrupt will only come when FIFO half full.

No comments for this page yet.

More options? Please login or register account. metropolitan-tundra