Reply by Andrew Nesterov August 26, 20082008-08-26
> Subject: Re: DM6437 UART - Problem for sending large data
> Posted by: "t...@yahoo.de" t...@yahoo.de tobiasneubert
> Date: Mon Aug 25, 2008 5:43 am ((PDT))
>
> Hallo Amol,
>
> I also had this problem some time ago with the UART of DM6437 EVM. The
> EVMDM6437_UART_... functions didn't seem to work correctly. So I wrote an own
> small UART-API which then worked for my purposes. I am not sure what was the
> reason, maybe a bug in the xmt- and recvReady() functions.
>
> Here are my functions, just check if they are useful for you.
>
> Tobias

Hi Tobias,

Your observation sounds interesting for me, particularly because I used
Spectrum Digital's uart test code to test DM6446 uart on the ARM side.
The loopback test went without errors. I remember that I did not changed
the method in the ready test functions, they worked as they had been designed
to test IIR to find out if data were received or if THR was empty.

Your code is essentially the same, it just do not use IIR for ready test,
instead it uses line status. What were the errors that you've ran into using
SD's code?

Rgds,

Andrew

> =========================>
> # include "evmdm6437_uart.h"
>
> UART_Handle priv_EVMDM6437_UART_open( Uint16 id, Uint32 baudrate )
> {
> UART_Handle uart_handle;
> Uint32 divisor;
> unsigned int curLSR;
>
> /*
> * UART clk / ( baudrate * 16 )
> * = 27,000,000 / ( 115200 * 16 )
> * = 14
> */
> divisor = 27000000 / ( baudrate * 16 );
>
> switch ( id )
> {
> case 0:
> uart_handle = ( UART_Handle )&UART_MODULE_0;
> break;
> case 1:
> uart_handle = ( UART_Handle )&UART_MODULE_1;
> break;
> default:
> return ( UART_Handle )-1;
> }
>
> uart_handle->regs->PWREMU_MGMT = 0; // Reset UART TX & RX components
>
> b_usleep( 100 );
>
> uart_handle->regs->DLL = ( divisor & 0xff ); // Set baud rate
> uart_handle->regs->DLH = ( divisor >> 8 ) & 0xff;
>
> uart_handle->regs->FCR = 0x0007; // Clear UART TX & RX FIFOs
> // Enable TX & RX FIFOs 14-byte
> uart_handle->regs->IER = 0x0000; // Disable interrupts
> uart_handle->regs->LCR = 0x0003; // 8-bit words,
> // 1 STOP bit generated,
> // No Parity, No Stick paritiy,
> // No Break control
> uart_handle->regs->MCR = 0x0000; // RTS & CTS disabled,
> // Loopback mode disabled,
> // Autoflow disabled
>
> uart_handle->regs->PWREMU_MGMT = 0x6001; // Emulation Free,
> // Enable TX & RX componenets
>
> curLSR = uart_handle->regs->LSR; // clear error bits by reading LSR
>
> if ( ( uart_handle->regs->IIR & 0xC0 ) == 0xC0 )// Check FIFOs are Enabled
> return uart_handle;
> else
> return ( UART_Handle )-1;
> }
> Int16 priv_EVMDM6437_UART_xmtReady( UART_Handle uart_handle )
> {
> return uart_handle->regs->LSR & (1<<5);
> }
> Int16 priv_EVMDM6437_UART_rcvReady( UART_Handle uart_handle )
> {
> unsigned int curLSR = uart_handle->regs->LSR;
> if ( curLSR & 0x9E) {
> ++s_nRecvErrors;
> }
> return curLSR & 1;
> }
> void priv_EVMDM6437_UART_getChar( UART_Handle uart_handle, unsigned char* data )
> {
> *data = uart_handle->regs->RBR;
> }
>
> void priv_EVMDM6437_UART_putChar( UART_Handle uart_handle, unsigned char data )
> {
> uart_handle->regs->THR = data;
> }
>