View previous topic :: View next topic |
Author |
Message |
xlh1460
Joined: 28 Jul 2010 Posts: 10
|
Problem with RS232 Baud Rate on PIC18F4620 on Picdem Z clone |
Posted: Thu Sep 23, 2010 6:29 pm |
|
|
I have programmed the following into the chip:
Code: |
#include <18F4620.H>
#fuses HS, NOWDT
// Enable delay functions with 4 MHz clock
#use delay(clock=4000000)
#use rs232(uart1, baud=9600)
void main() {
printf("PIC16F628 alive\n\r"); // send alive message
while(true) {
putc(getc()); // echo the received characters
}
}
|
The board has a 4Mhz crystal installed but the baud rate is out by a factor of 4.
I have set it to 9600 in the code but I have to set my terminal to 2400 for the communication to work.
Any idea what I am missing?
Thanks. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 23, 2010 7:08 pm |
|
|
Did you buy the board ? Post a link to the webpage for it. |
|
|
xlh1460
Joined: 28 Jul 2010 Posts: 10
|
|
Posted: Thu Sep 23, 2010 7:11 pm |
|
|
No, I built it myself using the schematic in the PicdemZ User Guide. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 23, 2010 8:27 pm |
|
|
Quote: | #include <18F4620.H>
#fuses HS, NOWDT
// Enable delay functions with 4 MHz clock
#use delay(clock=4000000)
#use rs232(uart1, baud=9600)
void main() {
printf("PIC16F628 alive\n\r"); // send alive message
while(true) {
putc(getc()); // echo the received characters
}
} |
The #include and the printf don't match.
But anyway, remove the HS fuse and change it to INTRC_IO and see if
it now works.
If it doesn't work, there's probably something wrong with your
programmer. It may not be programming the correct oscillator fuse. |
|
|
xlh1460
Joined: 28 Jul 2010 Posts: 10
|
|
Posted: Thu Sep 23, 2010 8:39 pm |
|
|
PCM programmer wrote: |
The #include and the printf don't match.
|
Good eye.
I modified a canned program for my chip and didn't both with the printf.
PCM programmer wrote: |
But anyway, remove the HS fuse and change it to INTRC_IO and see if
it now works.
If it doesn't work, there's probably something wrong with your
programmer. It may not be programming the correct oscillator fuse. |
Thanks for the suggestion, I will try that.
I ran into some issues with the Microchip Zigbee demo application and found that I had issues with it unless I enabled IESO in the fuses.
I am thinking that my external oscillator has gone south on me. |
|
|
xlh1460
Joined: 28 Jul 2010 Posts: 10
|
|
Posted: Thu Sep 23, 2010 8:44 pm |
|
|
INTRC_IO did the trick, the program is using the correct Baud rate.
Time to check the external oscillator I guess.
Thanks again. |
|
|
|