Just testing a new build max232 <-> pic 16f1827 pcb I've had made, found a strange issue.
Board initialises okay, and my demo program to just send a single byte to the pc worked. So I made the program a bit more complex and tried to send a sentence...
"Welcome to the world little microcontroller!"
Anyway about half the data was garbled, so I checked the baud rates, checked the registers and am still no better for it. I did think it was a baud rate issue as asynch is so sensitive to it, I know with a 4mhz crystal I can expect some error (0.16% with a baud of 9600) but this is a little much
Anyway, I've not solved the problem but I have shed a little light on it - I set up two examples:
Program one:
Send two bytes in sequence, 127 and 128, with a 500ms gap between each byte, continuously.
Result?
128 126 128 126 128 126 ...-> and so forth
Program Two
Count from 0 to 255 (sending each number to the pc) with a 50ms gap.
Result: 00 00 02 02 04 04 06 06 08 08
It's almost like the LSB is stuck in a rut!
Has anyone any suggestions? Just spent a lot of time googling because I wanted to figure it out but drawing a bit of a blank now. No doubt a lot of tomorrow will be spent in the baudrate part of the datasheet (minds gone too fuzzy now).
Sorry if this post is a bit breif, only got internet connectivity for 5 minutes but if there's anything needed to know I'll post it up asap.
Board initialises okay, and my demo program to just send a single byte to the pc worked. So I made the program a bit more complex and tried to send a sentence...
"Welcome to the world little microcontroller!"
Anyway about half the data was garbled, so I checked the baud rates, checked the registers and am still no better for it. I did think it was a baud rate issue as asynch is so sensitive to it, I know with a 4mhz crystal I can expect some error (0.16% with a baud of 9600) but this is a little much
Anyway, I've not solved the problem but I have shed a little light on it - I set up two examples:
Program one:
Send two bytes in sequence, 127 and 128, with a 500ms gap between each byte, continuously.
Code:
uart1_write(128);
delay_ms(500);
uart1_write(127);
delay_ms(500);
Result?
128 126 128 126 128 126 ...-> and so forth
Program Two
Count from 0 to 255 (sending each number to the pc) with a 50ms gap.
Code:
while (1) {
uart1_write(counter);
counter++;
delay_ms(50);
}
Result: 00 00 02 02 04 04 06 06 08 08
It's almost like the LSB is stuck in a rut!
Has anyone any suggestions? Just spent a lot of time googling because I wanted to figure it out but drawing a bit of a blank now. No doubt a lot of tomorrow will be spent in the baudrate part of the datasheet (minds gone too fuzzy now).
Sorry if this post is a bit breif, only got internet connectivity for 5 minutes but if there's anything needed to know I'll post it up asap.
Last edited: