This query pertains to serial communication between the PC and a
DSP chip - ADSP2181 via the UART - 16C550. I have problems in
establishing synchronization. I am using the polled mode of
operation, in which i have to poll the UART registers to get to
know of the status of communication.
The simple routine that i attempted was this :
(after the PC serial port initialization)
I send some data from the PC to the DSP (via UART) and in the
DSP, i read this data by checking bit 5 of the Line Status
Register(LSR), which indicates whether new data is available in
the Recieve Holding Register(RHR).
I send the data that I read in the above manner immediately back
to the PC, by checking bit 0 of LSR to see if the Transmit
Holding Register is available for writing.
On the PC, i do a blocked read (system call read()), to collect
the data thus sent from the DSP.
The problem is,
lets say, i send 20 bytes from the PC to the DSP and back to the
PC, the last byte is not recieved on the PC. The next time i
start this session, (after flushing the UART FIFOs and
re-initializing the PC serial port), the last byte of the
previous session comes out as the fisrt byte of this session,
followed by this session's data, except the last one, again.
I have tried doing extra writes from the DSP, continuing the
blocked read on the PC and this doesnt seem to work.
How do I go about it?