itsanjan / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

abilty to change data bit, stop bit, parity #573

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What change would like to see?

The ability to change all the parameters of the serial ports on the arduino 
boards e.g. data bit, stop bit, etc

Why?

I find myself looking at serial devices that do not work out of the box with 8 
bits and standard arduino settigns

Would this cause any incompatibilities with previous versions?  If so, how
can these be mitigated?

if called from Serial.start(19200), it may require tweaks if the paramater were 
to be changed to serial.start(19200,7,O,1,OFF,OFF,ON,OFF) for example

Original issue reported on code.google.com by frozenf...@gmail.com on 28 Jul 2011 at 8:25

GoogleCodeExporter commented 9 years ago
Exactly what im looking for!

But i dont understand what you mean with "OFF,OFF,ON,OFF"

Original comment by bo...@owee.de on 20 Sep 2011 at 6:37

GoogleCodeExporter commented 9 years ago
to be honest, i cant remember what the ON,OFF boolean flags do..

it is possible to do all this, just change the bit array (hidden in the manual 
for each port and then power cycle the board. something like

bitarray = B'00000000'

does the trick

Original comment by frozenf...@gmail.com on 20 Sep 2011 at 7:28

GoogleCodeExporter commented 9 years ago
page 226 from http://www.atmel.com/dyn/resources/prod_documents/doc2549.pdf has 
all the info for this topic. if the IDE could automate these bits, then that 
would be fantastic!

Original comment by frozenf...@gmail.com on 20 Sep 2011 at 7:54

GoogleCodeExporter commented 9 years ago
I know that it isn't "that" easy to do all modes of a uart with only one Byte.
On a AtMega644P for example you need to change the registers UCSRxB and UCSRxC 
to configure a 9N1 for example (UCSZx0,UCSZx1,UCSZx2)
But this should defenitly be supported by the serial lib!

Original comment by bo...@owee.de on 21 Sep 2011 at 7:12

GoogleCodeExporter commented 9 years ago
from a project (comments might be wrong), but this is an alternate structured 
way to follow the manual and apply the settings

        //Servo drive port setup
        //
        //UCSR2C IS =
        //UMSELx1, UMSELx0, UPMx1, UPMx0, USBSx, UCSZx1, UCSZx0, UCPOLx
        UCSR2C = B00000000;  
        //set serial port to none
        UCSR2C = UCSR2C | B00000000;
        //set serial word length to 8
        UCSR2C = UCSR2C | B00000110;
        //set serial stop bit to 1
        UCSR2C = UCSR2C | B00000000;

8/none/1 seems to be the default I think. windows hyperterminal allways seems 
to auto detect settings if you input them incorrectly.

9 data bits is something I have not come across. If it is settable I allways 
try to change it to 8/Odd/1, 

only 8/7, Even/none/Odd, 1/2 should exist, bloody 9 data bit devices.

alternatively alternatively, someone could just make a profibus/DP shield and 
my problems would be over......

Original comment by frozenf...@gmail.com on 21 Sep 2011 at 7:41

GoogleCodeExporter commented 9 years ago

Original comment by dmel...@gmail.com on 11 Mar 2012 at 5:05