HW999, Paul:
Serial Parity, Stop Bits, 7-8-9-10 bit...
I started looking at how the Serialx.begin(baud, format), on how the different formats are handled and what comes out of the IO pins. For the most part this is something I never worry about, as everything I use, is normally 8N1...
However thought I would take a look and see if my Logic Analyzer likes the data stream for the different parity, character bits. It didn't with several of them, example 8E1 or 8N1, the 9th (Parity) bit was stuck as a 1, so there were lots of parity errors. Currently I am only playing with the Serial4 code as it is common with the other SerialX objects (except 6), but only the beta boards have Serial4... Looks like by default the 0x40 bit of Serial4_C3 is stuck (initialized) as a 1, so always outputs HIGH. Setting C3 to 0 in the format code, appears to fix it, such that the calculated parity bit is output in this mode.
I think maybe I need to try some of the other Serial objects on T3.2 to see if similar issue.
As for 1 versus 2 stop bits, wondering if it makes sense to maybe change the format bits, in particular:
Code:
// bit0: parity, 0=even, 1=odd
// bit1: parity, 0=disable, 1=enable
// bit2: mode, 1=9bit, 0=8bit
// bit3: mode10: 1=10bit, 0=8bit
// bit4: rxinv, 0=normal, 1=inverted
// bit5: txinv, 0=normal, 1=inverted
// bit6: unused
// bit7: actual data goes into 9th bit (only in optional #ifdefed out)
That Currently 2 stop bits is encoded into bit 2, wonder if it could be in it's own bit, as we actually have 32 bits to pass. For my playing/testing of things like 8E2, I did define bit 8 as number of stop bits. I currently still special case if: format & 0x0f == 4 as 8N2, but wondering if it would hurt anything to instead define it as 0x100
Code:
#define SERIAL_8N2 0x0100
Now to test T3.2 to see what it generates.
Update: Testing on T3.2 8E1 and 8O1 appear to work without change
Likewise it appears to work on T3.6 on Serial1 without change
Update2: Tested on T3.6 with Serial1, 2, 3, 5 and have not gotten back into the state where the Parity bit was stuck high yet. Maybe the hardware got into some weird state yesterday...