Hi!
It seems that I'm not alone!

first I found a bug in the code I posted.

I define:

#define GENERIC_READ_WRITE 0xC0000000

but then I don't use it:

hPort = CreateFile ("COM1", // Pointer to the name of the port
GENERIC_READ | GENERIC_WRITE,
// Access (read-write) mode
0, // Share mode
NULL, // Pointer to the security attribute
OPEN_EXISTING, // How to open the serial port
0, // Port attributes
NULL); // Handle to port with attribute to copy

sorry, but the code I posted were not exactly the one I used when I do the test!, so the correct line is:

hPort = CreateFile ("COM1", // Pointer to the name of the port
GENERIC_READ_WRITE,
// Access (read-write) mode
0, // Share mode
NULL, // Pointer to the security attribute
OPEN_EXISTING, // How to open the serial port
0, // Port attributes
NULL); // Handle to port with attribute to copy

second.

the trouble you have should be the speed. How do you test the 1200?
I first do a hypertérminal connection between 2 instances, then between hypertérminal and a code made in LiteC or wathever and finally I test the serial connection between the microcontroller and the hyperterminal or liteC.

When all this doesn't work, take an osciloscope! it never lies.

If you look my code, I set the baudrate and then I read the state of the comm and display specifically the baudrate, because I have told one baudrate and the port were in another and I've getting more than one character as I tx one! Another trouble I had in LiteC was that characters enclosed with ' doesn´t be the ones I wanted till I found str_to_asc!
I lool for CHR() and ASC() function of Pascal, Basic etc but LiteC has their own's.

If you have no success in set the baurate, try the Windows configuration that stablish the "Default" and change int to suit your need's. But theoretically you should set the communication parameters the way I do.

Try to place a delay between the set and the get functions to be sure I don´t know if needed.

saludos

Juan

Last edited by charrua; 11/24/08 23:54. Reason: my bad english!