Go Down

Topic: Mods to HardwareSerial to handle 9-bit data (Read 7 times) previous topic - next topic

zarobhr

this is exactly what i am looking for, but i am not successful in getting it to work.
using arduino 1.01

I am using an Ardino UNO and have a max232 connected to pins 0 and 1

at the device i can see the bytes i am sending from the UNO but none of them have the ninth bit set

i have download and installed the revised hardwareserial files

and am using the following in the setup
Serial.begin(19200,true);

and

in the loop
Serial.write9bit(0x03); //wakeup device at address
delay (10);
Serial.write(0x17);      // command
delay (10000);


Nick Gammon

It looks like those amendments didn't work perfectly with 1.0.1 of the IDE.

The files above (same names) have been amended now and should work with 1.0.1. This test checked out on the logic analyzer:

Code: [Select]

void setup ()
{
  Serial.begin (115200, true);  // 9 bit mode
  Serial.println ("--- starting ---");
}  // end of setup

int i;

void loop ()
{

  for (i = 0; i <= 0x1FF; i++)
    Serial.write9bit (i);  // send another byte
 
}  // end of loop

zarobhr

thanks i will test it in my code tommorrow

davidb

Hi Nick et al.,
I know this topic is fairly old, but figured it was best to ask the question here vs. starting a new thread?

I recently got involved in a project where 9-bit serial data was required, and not really knowing what to do I was pretty excited to see Nick's work here (thanks, Nick!).

So my quick question is whether or not the mods to the library are specific to AVR-based micros, or more specifically will the mod work with ARM-based micros? I just don't know enough about how libraries work (yet) to be able to answer this question myself.

Thanks in advance for any pointers, and thanks again Nick for your work here!

Cheers,
David

Nick Gammon

You are welcome.

The mod was specific to the way that the hardware on this particular processor worked. It probably can be carried over to similar ones in the same line (eg. the Mega2560).

As for ARM ones, they would have different hardware interaction. Quite possibly they might support some sort of 9-bit serial, however I just don't know.

Go Up