RacingTornado / fx2lib_serial_uart

Uses the newer version of FX2LIB with custom device descriptors
GNU Lesser General Public License v3.0
0 stars 0 forks source link

UART kind of works #2

Open RacingTornado opened 8 years ago

RacingTornado commented 8 years ago

UART using bitbanging and a timer running at 3 times the speed(33us for a 104us bit time), kind of works. However , sometime , it appears as though wrong data gets written into the buffer. I am not really sure how to solve this issue apart from increasing the speed of the timer, however this would mean higher baud rates will have similar problems. PA0 is the TX pin and the PA1 is the RX pin @mithro @rohit91

mithro commented 8 years ago

You need some type of queue/buffer between the USB and the output. The USB stuff should write into the queue and then the bit banging stuff should read from the queue.

RacingTornado commented 8 years ago

The problem isnt while transmitting a character from FX2 to UART. It is while receiving a character from UART into FX2. A buffer along with a timer is being used(62 characters or timer expiry)

mithro commented 8 years ago

You obviously have a buffer on both input and output; IE

USB -> BUFFER -> UART
UART -> BUFFER -> USB

You can test both UART -> BUFFER and BUFFER->UART bits independently of the USB stack to verify that you are sending / receiving the UART side correctly.

If adding the USB then breaks things, it sounds like you might have issues with interrupts taking to long to be serviced and missing stuff.

RacingTornado commented 8 years ago

What I do is this UART->BUFFER->UART , so no usb

mithro commented 8 years ago

Okay, then that should be trivial to get working.

RacingTornado commented 8 years ago

By increasing timer , yes. Maybe for lower baud rates. But 3x should be enough. I have written the interrupt routines again fully. It is as short as it can be without missing pulses. Any other suggestions?

mithro commented 8 years ago

First you want to understand what is causing the problem. Explain exactly to me what is happening inside the FX2 which is causing the corruption. Draw a diagram.