mega2560 serial data bits

Hi everyone,

I am having a problem setting the serial data bits on my mega 2560

I have two serial RS232 devices, both which work in hyperterminal. however, both do not use the standard data bits to the arduinio.

First of all, am i right in thinking that

USART0 = Serial 0: (RX) and 1 (TX) ( connected to the USB chip so best not to use) USART1 = Serial 1: 19 (RX) and 18 (TX) USART2 = Serial 2: 17 (RX) and 16 (TX) USART3 = Serial 3: 15 (RX) and 14 (TX)

I have my two devices going into a max232cpe voltage converter chip and this does seem to work with one of the devices. I can read data from the mega2560>>max232>>hyperterminal. on Serial.Println("hello"), however i think hyperterminal must do some analysis and changes the data bits on the fly to get the data on screen. this does not help me.

to change the data bits, i need to change UCSRxC, correct?

(UMSEL11 UMSEL10 UPM11 UPM10 USBS1 UCSZ11 UCSZ10 UCPOL1) so looking at Table 22-7 (pg 226)in the datasheet, I have

UCSR1C = B00000110 for 8 data bits UCSR1C = B00000100 for 7 data bits

UCSR1C = B00110000 for Enabled, Odd Parity UCSR1C = B00100000 for Enabled, Even Parity

Does changing these values require any other changes or power cycles to take effect? beacuse I cant get my known working device to talk :(

thanks in advance!

Tom

Hi

Did you get this resolved , as I'm having the same issue with the same board

The pins are right and I'm pretty sure your register bits are correct, show us the code that sets them.

Once you've done a Serialx.begin() I would think that the library code doesn't touch those bits again, I can see nothing in that register that needs setting after the port is initialized.


Rob

I did get this fixed in the end. I ended up altering the bits to suit the device, then delay(100), then open the port. i.e dont change settings if the port is open...... but noone tells you that 8)

so you do change UCSRxC, where x is 1 to 3 to alter the settings

and windows hyperterminal does hinder you by auto negotiating the settings :veryveryveryangry:

I have about the same issue- could you please post the code you made to work sucessfully in the end?
That would be really great :slight_smile: