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 CCS Technical Support

rs-232 out not good

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



Joined: 11 Jun 2005
Posts: 38

View user's profile Send private message

rs-232 out not good
PostPosted: Sat Jun 11, 2005 4:32 am     Reply with quote

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







PostPosted: Sat Jun 11, 2005 5:07 am     Reply with quote

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

View user's profile Send private message

PostPosted: Sat Jun 11, 2005 7:14 am     Reply with quote

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 !! Very Happy Very Happy
now is all good !
was 8MHz clock
thanks
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