-
Notifications
You must be signed in to change notification settings - Fork 376
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
Fix 7-bit support for teensy4 and teensy3 #665
base: master
Are you sure you want to change the base?
Conversation
It turns out that without the fix, the transmit properly sends 7-bit data, but receive still sometimes sets the 8th bit high. I need to explore more... |
On my journey to understanding this better — It's been a while since I've explored this in depth (for TeensyDMX) — I think I'm re-discovering that the "data" includes everything but the start and stop bits. This means that my proposed solution, setting M7, will really cause a 6-bit data byte if there's parity. If I'm right, then my solution isn't correct. I'm closer... |
See: https://forum.pjrc.com/threads/71505-7-bit-support-seems-to-be-missing-on-Teensy-4 That top bit, because it's the last in the stream, turns out to be the value of the parity bit. On to a fix... |
Okay, I think I got it. There has to be an appropriate mask depending on the mode. I tested this with a 7E1 device, both directions. |
deb34ce
to
5454196
Compare
I updated the PR to include a commit for fixing teensy3 7-bit support. Tested with the same 7E1 device. |
Here's my logic for fixing this: All formats other than 7-bit don't set the parity bit when a user reads bytes. It is unexpected for the 7-bit format to set the parity bit. This PR fixes this case. If this is not fixed, then, in my opinion, it should be documented. |
Quick update: As I mentioned on the forum thread. The other 8 bit and 9 bit also return the parity. But by default the software FIFO queues are 8 bits per element, so the data is lost. There is a #define commented out in the HardwareSerial.h that enables the FIFO queue to be uint16_t instead and it does return the actual data including the parity bit. Posted test sketch in the forum thread, but with that bit on, it outputs:
Note in each of the output lines for the different Formats I output A-P and I also now after the : in each line try to output the top values for these formats. As to make sure whole range is returned. |
Don't include the parity bit for returned data.
Don't include the parity bit for returned data.
Fixes #664