Hello,
I'm using Keil to write data over the serial port.
ubyte b=0x0A; printf("%c",b);
with this code I reveive two bytes: “0x0D” and “0x0A” in PC instead of “0x0A”. This happens only with “0x0A”. What's wrong with it?
Thanks Senmeis
PC is the receiver. Do you mean the problem is the Microcontroller or the PC? Are there any ways still to use printf()? Anyway it is a standard function in keil.
As far as I remember, the default implementation of putchar() in C166 expands '\n' into '\r\n'. Besides, the implementation is blocking. You should implement your own putchar(). You can take the default implementation and remove the '\n' expansion. If you need interrupt-driven serial I/O, have a look at the traffic example program.