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

wrong uart reading in 18F4431

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



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

wrong uart reading in 18F4431
PostPosted: Mon Apr 14, 2008 7:35 am     Reply with quote

I have trouble with18F4431 receiving data from 12F675. The Getc function returns garbage.
Here are the codes:
sender:
Code:

....
#use rs232(baud=9600, xmit=PIN_A4, rcv=PIN_A5)
....
char c;
....
putc(c)
....


receiver:
Code:

#use rs232(baud=9600, xmit=PIN_С6, rcv=PIN_С7)
....
char c;
....
c=getc(); //already wrong
printf(lcd_putc, "%c", c);

And the garbage depends on what's sending.
The signal from transmitter is OK. In Proteus all OK too.
andredurao



Joined: 24 Apr 2006
Posts: 15

View user's profile Send private message MSN Messenger

Re: wrong uart reading in 18F4431
PostPosted: Mon Apr 14, 2008 7:58 am     Reply with quote

strange... I tried to simulatte 18f4431 and my version of proteus didn't have the simulator model for that device,....wich version are you using?
Matro
Guest







PostPosted: Mon Apr 14, 2008 7:59 am     Reply with quote

Are both PIC running at the same voltage?

It's better to set up parity, bits and stop in the #use rs232 directive.

Matro.
Ttelmah
Guest







PostPosted: Mon Apr 14, 2008 9:08 am     Reply with quote

What clock source are you using?.
Fuses?.
Clock statement?.
Connections (remember the ground...).
Power source?.

Best Wishes
40inD



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

Re: wrong uart reading in 18F4431
PostPosted: Mon Apr 14, 2008 10:45 pm     Reply with quote

andredurao wrote:
strange... I tried to simulatte 18f4431 and my version of proteus didn't have the simulator model for that device,....wich version are you using?

18F4431 was only one free chip in my component box now, and I used it for simple tasks like rs232 and lcd output. For this reason I replaced it in Proteus with 18F452. The code works.
Marto wrote:
Are both PIC running at the same voltage?

It's better to set up parity, bits and stop in the #use rs232 directive.

Not only at same voltage - at same DC source.
I tried to set many combinations of rs232 parameters - not helps.

Ttelmah
For 18 i use 40Mhz crystal, for 12 - internal osc 4 MHz.
PICs are connected directly pin-to-pin.
Power source - 7805, 1 source for both pics.
Can't post fuses now because the code is at home and I - at work now Smile
Ttelmah
Guest







PostPosted: Tue Apr 15, 2008 2:26 am     Reply with quote

Do you mean a 40MHz _crystal_, or a _oscillator module_?.
If the former, then this is your problem.
The maximum frequency specified for the internal oscillator module, using a crystal, on this chip, is 25MHz. Table 25-4 in the data sheet. What happens if you go over this, is that the oscillator generally runs, but locks onto the wrong overtone on the crystal, and typically gives 3/4 the specified frequency. No wonder the serial rates would be wrong....
To run most 18 chips at 40MHz, requires either using the PLL, or using an external oscillator module.

Best Wishes
40inD



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

PostPosted: Tue Apr 15, 2008 2:54 am     Reply with quote

Hmmm... i will try 20Mhz crystal, but i always used 40 MHz with projects on this pic and never had problems... but i never used uart in this projects...
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