View previous topic :: View next topic |
Author |
Message |
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
wrong uart reading in 18F4431 |
Posted: Mon Apr 14, 2008 7:35 am |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
andredurao
Joined: 24 Apr 2006 Posts: 15
|
Re: wrong uart reading in 18F4431 |
Posted: Mon Apr 14, 2008 7:58 am |
|
|
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? |
|
![](templates/subSilver/images/spacer.gif) |
Matro Guest
|
|
Posted: Mon Apr 14, 2008 7:59 am |
|
|
Are both PIC running at the same voltage?
It's better to set up parity, bits and stop in the #use rs232 directive.
Matro. |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Mon Apr 14, 2008 9:08 am |
|
|
What clock source are you using?.
Fuses?.
Clock statement?.
Connections (remember the ground...).
Power source?.
Best Wishes |
|
![](templates/subSilver/images/spacer.gif) |
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
Re: wrong uart reading in 18F4431 |
Posted: Mon Apr 14, 2008 10:45 pm |
|
|
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](images/smiles/icon_smile.gif) |
|
![](templates/subSilver/images/spacer.gif) |
Ttelmah Guest
|
|
Posted: Tue Apr 15, 2008 2:26 am |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
40inD
Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
|
|
Posted: Tue Apr 15, 2008 2:54 am |
|
|
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... |
|
![](templates/subSilver/images/spacer.gif) |
|