Hi,
I am using NXPs' 16c554D. I have initialized it to read/write at 38400bps. But I am getting parity errors. Can anybody who has written a working piece of code, post it here.
This is my code. Clock freq is 14.7456MHz. Would appreciate if anybody lets me know what is wrong in this code. The Read and write signals are enabled in the read and write routines respectively.
WriteStrobe = 1; // Active Low signal
ReadStrobe = 1;
RstHi = 0; // Reset pin for 16c554 should be low.
PMCS = 0; // enable UART Channel D
A2 = 0;
A1 = 1; // Write to FCR,
A0 = 0;
ParallelPortWrite(0x03) ; // Fifo Enable, FIFO Reset, DMA Disabled
Nop();
A2 = 0;
A1 = 1; // Write to LCR, Even Parity, 5 bytes,Divisor Enable
A0 = 1;
ParallelPortWrite(0x98) ;
Nop();
A2 = A1 = A0 = 0;
ParallelPortWrite(0x18) ; // Write to DLL. Divide Clock Frq by 24.
Nop();
A2 = 0;
A1 = 0;
A0 = 1;
ParallelPortWrite(0x00) ; // Write to DLM
Nop();
A2 = 0;
A1 = 1; // Write to LCR, Even Parity, 5 bytes,Divisor Disable
A0 = 1;
ParallelPortWrite(0x18 ) ;
Nop();
A2 = 0; // Write to IER
A1 = 0;
A0 = 1;
ParallelPortWrite(0x00); // Disable all the interrupt
while(1)
{
LSR_Val = ReadLSR() ;
if( (LSR_Val & 0x0001) == 0x0001) // If Data is Ready, read from the RHR
{
A2 = A1 = A0 = 0; // Receive Holding Register,
Nop();
Nop();
RHRData[j++] = ParallelPortRead();
}
if (j==15)
{
j=0;
}
}
Regards