views:

476

answers:

1

I'm trying to get a simple serial reader going in C# to read info from an rs232. I'm using VS2008. I can receive data fine with hyperterminal and python but I keep getting parity errors every time I try to transmit a character to C#. Number's work fine, it's just the characters. It's configured exactly the same as hyperterminal: 9600baud, 1 stopbits, no parity, no handshakes. What could be causing only the characters to mess up and not the numbers?

+2  A: 

How can you have parity errors when the configuration is "no parity"?

Are you seeing failures of a checksum stored in the data stream (as opposed to RS-232 parity bits)? Are you getting exceptions when using the C# serial port class?

Show some data dumps.

You might also try realterm, which can show you the hexadecimal value of raw characters received. It's also easy to convert C# byte arrays into hex. Then compare both to see if characters are missing or changed or what the actual problem is.

We can't suggest any solutions until the failure is described a little better.

Ben Voigt
There are no exceptions. It's just printing out question marks which is what ParityReplace is set to. I'll try realterm ty.
silverbandit91
what crystal are you using for the dsPIC? Show the code that sets up the serial port on the PIC (especially the divider for the baud rate generator).This sounds more like a framing error than a parity error, which could happen sporadically if the baud rate is off by more than 1% or so (although this usually isn't a problem at 9600 baud, for 115200 baud I've had to choose crystals specifically made for RS-232 communications, like 11.059MHz)If the PIC was sending parity bits when the PC expected none, then there'd be a parity bit when the receiver was looking for a stop bit -- error.
Ben Voigt