-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Garbage @ 115200 #4
Comments
Yup, I can 100% confirm the bug now. Today I am testing HLK-LD1155H-24G sensor using Arduino UNO, at Baud rate 115200.
, I get correct output which means that the built-in Serial is working at 115200 baud rate, but not the CustomSoftwareSerial. |
I have successfully figured out how to read UART at 115200 baud rate for CSERIAL_8N1 on Arduino UNO, other configurations like 8N2/8E1/8O1/etc should similarly apply. The main difficulty is that since 16000000/115200=138.889, you need to read the RX pin every ~139 clock cycles which is not a lot. Every call to digitalRead() takes about 64 clock cycles, so you cannot think about it. And there is too little time to check for how many data bits, stop bits, or parity bit in different configurations. In addition, you need to be clear about how much time every line of code will take, and function calls must be avoided as much as possible because stack pushing/popping takes many clock cycles.
The above code is tested working on reading UART data from HLK-LD1155H-24G sensor, the idea is to use Timer1 counter to wait until the arrival of the next bit, avoid calling functions and try to use constants instead of variables. |
First of all, I wanted to thank you for the library, very helpful. It is unbelievable that Arduino has so many constraints in terms of communication.
Right now, I'm using your library, but I'm having troubles with the baudrate. I can only have good data a 9600 bps. Changing to 115200 everything is just garbage. Unfortunately, my application does not allow something less that 115200 bps. In order to test the library, I did the following program. The following code uses the default pins (0,1) to transmit the word "Hello world". But I only get reliable data at 9600. Any answer will be much appreciated it.
The text was updated successfully, but these errors were encountered: