Ill ask my question a different way. Has something been done / left / still to do with
A: Direct UART register maniplation such as the code I posted above
B: Has anyone got the new SerialX.begin(SPEED, SERIAL_XXX) to work correctly.
In my testing using an in-line external scanner my Arduino Mega 2560 is still transmitting 8N1 .. not 8E1 which I have been directing it to do (again see above code posted)
I did not even notice you could now use a second parameter in Serial.begin to specify the protocol. What version introduced this? The reference pages for Serial.begin in the 1.0.3 download do not refer to the extra protocol parameter but the on-line version does.
I do not have a Mega but after reading this thread and referring to the on-line documentation I can confirm the protocol parameter is working on a v2 UNO using 1.0.3 IDE. Below is the output. CH1 = 8N1, CH2 = 8O1 & CH3 = 8E1
It wasn't but after testing this still doesnt work.
Unfortunately neather does using the Serial3.begin(9600, SERIAL_8E1); command.
It doesnt actually transmit or recieve in 8E1 mode .. its still in 8N1.
I have tried this again in Arduino IDE 1.0.5 for Windows.
The last time it worked was in an old 023 version which is what i'm still having to use to get my program to work.
void setup() {
Serial.begin(115200); // Serial Monitor
Serial1.begin(115200); // Display
Serial3.begin(9600); // Device Comms
// ******************* Ardiuno Mega 2560 ***********************************************************
UCSR3C = ( UCSR3C & ~_BV(UPM00) | _BV(UPM01) ); // Arduino Mega 2560 even parity set
}
The above works in IDE 023, however the UCSR3C commands (direct register manipulation) compiles however doesnt change the internal registers any more (hence the 'its not supported comment) ... Im not worried about it being removed or disabled .. but as you will see below the replacement just doesn't work any more. There is nothing in my code that is fancy. Infact I have gone back to basics and run the same tests with example comms code with the same results.
void setup() {
Serial.begin(115200); // Serial Monitor
Serial1.begin(115200); // Display
Serial3.begin(9600, SERIAL_8E1); // Device Comms
// ******************* Ardiuno Mega 2560 ***********************************************************
//UCSR3C = ( UCSR3C & ~_BV(UPM00) | _BV(UPM01) ); // Arduino Mega 2560 even parity set
}
The above doesn't work in Ardiuno IDE 1.0.1,2,4 or 5.
My device receiving a command and all other low level logic tests confirm that the logic level is still being transmitted at 8N1.
UCSR3C = ( UCSR3C & ~_BV(UPM00) | _BV(UPM01) ); // Arduino Mega 2560 even parity set
I can't think of any reason that this would stop working in 1.0.x, either. Although I'd certainly have used at least one more set of parens... The AVR Microcontroller has no protection of anything, nor does the arduino environment. It can't stop you from re-writing the config register.
Ok so after running a new logic analysis tool I did a whole bunch of before and afters.
IDE 023
IDE 1.5 with direct register manipulation for 8E1
IDE 1.5 with Serial.begin(9600, SERIAL_8N1)
IDE 1.5 with Serial.begin(9600, SERIAL_8E1)
And it all tested good... accept I noticed one little difference between IDE 023 and IDE 1.5
I was using the serial.print command which in 023 output true bytes. In IDE 1.5 it outputs ASCII
Changed to serial.write and it fixed the issue
Only probably I have now is that the performance of the SDCard library i'm using has gone from about 8-7 times a second down to 3-4 times a second which is far too slow for my needs. Even after some tweaks, its just very slow.
Ill try mucking around with formatting of the cards.