|
|
View previous topic :: View next topic |
Author |
Message |
ferrarilib
Joined: 11 Jun 2005 Posts: 38
|
rs-232 out not good |
Posted: Sat Jun 11, 2005 4:32 am |
|
|
Hallo I am Mauro.
I am trying CCS c compiler and I don't know how work fine.
my code is simply this:
Code: |
#include <16F877a.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP
#use delay(clock=40000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
void main() {
while(1)
{
putc('U');
}
}
|
I have Max232 and C7->Rx e C6->Tx
The output isn't UUUU.
but
0x1F 0x1F 0x1F 0x1F 0x1F 0x1F 0x1F 0x1F
continuous...
I have tried with another Hex with another compiler and all is fine.
What can be my problem ?
Thanks |
|
|
Ttelmah Guest
|
|
Posted: Sat Jun 11, 2005 5:07 am |
|
|
The problem is your clock rate.
The 16F877a, has a maximum clock rate of 20MHz. Your '#use delay' line, is saying that the clock is running at 40MHz. This line is used for delays, but also to calculate the timings for the serial port. As such, the division is being set up based on an incorrect clock rate, and the data is coming out far slower than it should do. Looking at the values seen, I'd 'guess' that a single bit of the outgoing stream is being seen as five bits by the receiver, suggesting that your actual clock rate is perhaps about 8MHz.
Check your crystal frequency, correct the line, and it should work.
Best Wishes |
|
|
ferrarilib
Joined: 11 Jun 2005 Posts: 38
|
|
Posted: Sat Jun 11, 2005 7:14 am |
|
|
Ttelmah wrote: | The problem is your clock rate.
The 16F877a, has a maximum clock rate of 20MHz. Your '#use delay' line, is saying that the clock is running at 40MHz. This line is used for delays, but also to calculate the timings for the serial port. As such, the division is being set up based on an incorrect clock rate, and the data is coming out far slower than it should do. Looking at the values seen, I'd 'guess' that a single bit of the outgoing stream is being seen as five bits by the receiver, suggesting that your actual clock rate is perhaps about 8MHz.
Check your crystal frequency, correct the line, and it should work.
Best Wishes |
Thanks !!
now is all good !
was 8MHz clock
thanks |
|
|
|
|
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
|