Posted on arduiniana already in the hope that Mikal will see it but is awaiting moderation at the moment and thought I'd throw it open to the boards in case others *might* know the answer to this..
Having a bit of a problem with what I think is down to a writing baud rate issue with NSS..
I have the PC connected to the Duemilanove via USB, then pin 3 of the arduino (Tx) connected to the serial connection on a Milford Instruments LCD display screen. Which accepts baud rates of 9600 or 2400 depending on the baud jumper, is 8bit, no parity and one stop bit.
I have the baud jumper installed so it should be reading at 9600 baud.
Pin 3 of the Duemilanove is connected to a level converter to bring it to 5v. I have also tried without the level converter inverting the lcd NewSoftSerial in the sketch but same results.
In this instance / tiny project the Duemilanove should be acting as a USB to serial converter. The sketch is as follows:
NewSoftSerial lcd(2, 3);
char c = Serial.read();
So it should be reading from Serial (1 char at a time) then printing to the LCD display via pin 3 (additional Serial prints for debugging)..
At the PC side I have a python script to send the commands (clear the LCD display, reset the cursor position and send some 'test' text):
for i in range(len(string)):
print "Tx: %d" % ord(string[i])
c = ser.read()
print "Rx: %d" % ord(c)
o = ser.read()
print "Overflow: %s" % o
ser = serial.Serial(port='/dev/ttyUSB0', baudrate=9600, timeout=1)
echo(chr(254) + chr(1))
echo(chr(254) + chr(0))
At 9600 baud either side of the Arduino, data is getting through to the display screen but about 50% of the time at least 1 of the 4 characters that make up the initial string is garbled. However the messages that come back through the USB serial port to the PC are always correct and there's no overflow.
Connecting the LCD display directly to the PC with a serial cable or through a USB to serial converter (PL2303) it works 100% of the time fine.
I tried the lower baud rate that the LCD provides (2400) which appeared to make things marginally better (slightly more consistent with the correct message appearing) - probably somewhere between 70% - 80% correct on the display but still not accurate all of the time.
I'm assuming the board isn't writing with NSS accurately, and looks like a baud issue when writing with NSS.. Any ideas / things to test?
P.S. I've also just tried sending the same bytes / messages directly from the sketch (without the Serial read) and same problem..