I try to use arduino to interface with a serial item. This item sends data via rs232 at 19200 baud, the spec says it uses 8 data bits, odd parity and 2 stop bits.
It seems, that arduino defaults to 8n1.
Should it be enough to set the register UCSR0C = B00111110; according to the atmel spec to force the right com-config? I placed the statement in the setup-function and also i tried it inside the wiring_serial.c .
It seems that arduino receives the right number of bytes, but not with the right content....
Has anybody else changed the behaviour of the serial post of the arduino to something other than 8N1 and had success?
yes, this seems to be the same source where I got my idea from... I think I need some more ones than your code to do 8 data bits, odd parity and 2 stop-bits, but so far this is not the point.
my point is where do I have to use this command, i.e. where do I have to set the UART control register to prevent it from being changed by the setup routine but also to be sure that it does what it should do.
Is it possible and allowed to change this register on the fly (after Serial.begin() ) or does this prevent the UART from functioning the right way ? Any idea?
Is it possible and allowed to change this register on the fly (after Serial.begin() ) or does this prevent the UART from functioning the right way ? Any idea?
I dunno, but while we're waiting for the experts to chime in, try putting it in setup after Serial.begin(). If that doesn't work, try it after Serial.begin().
great, (I assume that you suggested "try it before, if it doesn´t work, try it after") I had the same idea.... but as I have written in my first posting I get strange data from the serial input. So I´d like to be sure that the arduino-side is set up the right way.
Anybody out there who has managed a serial connection via built-in UART with 8o2 config ?
just for info you can always setup the register to suite the config to your needs.
My problem was that I did not mention that there was a max232 in the device so arduino tried to interpret real RS232-levels. Taking the sig from max input-pin with TTL level works well.