Open RacingTornado opened 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.
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)
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.
What I do is this UART->BUFFER->UART , so no usb
Okay, then that should be trivial to get working.
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?
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.
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