CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Problem with RS232 Baud Rate on PIC18F4620 on Picdem Z clone

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
xlh1460



Joined: 28 Jul 2010
Posts: 10

View user's profile Send private message

Problem with RS232 Baud Rate on PIC18F4620 on Picdem Z clone
PostPosted: Thu Sep 23, 2010 6:29 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 7:08 pm     Reply with quote

Did you buy the board ? Post a link to the webpage for it.
xlh1460



Joined: 28 Jul 2010
Posts: 10

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 7:11 pm     Reply with quote

No, I built it myself using the schematic in the PicdemZ User Guide.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 8:27 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 8:39 pm     Reply with quote

PCM programmer wrote:

The #include and the printf don't match.


Good eye. Smile

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

View user's profile Send private message

PostPosted: Thu Sep 23, 2010 8:44 pm     Reply with quote

INTRC_IO did the trick, the program is using the correct Baud rate.

Time to check the external oscillator I guess.

Thanks again.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group