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

Problem with RS232

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



Joined: 12 Jul 2007
Posts: 32

View user's profile Send private message

Problem with RS232
PostPosted: Tue Feb 26, 2008 4:48 am     Reply with quote

Hallo everybody,
I use a PIC 18F2480, the MAX232CPE and Docklight.
When I want to send a string via RS232 I get nonsensical strings. I am sure that the capacitors are right attached.
Where could be the fault?

Thanks for help!

P.s.: below a part of my code:
Code:
#include <18f2480.h>
#device *=16
#device ADC=10
#use delay(clock=8000000)
#fuses NOWDT,HS,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP
#use rs232(baud=9600,xmit=PIN_C6,rcv=PIN_C7,BRGH1OK,stream=debug)

void main()
{
   printf("\n\rspeed (hex): ");
   V = fgetc(debug);
   puts("\nMeasured data:\n");
}
Ttelmah
Guest







PostPosted: Tue Feb 26, 2008 5:13 am     Reply with quote

Obvious things:
1) Is your crystal 8MHz?.
2) Is the serial program set to 9600BPS?.
Count how many characters you 'see' when the program starts. If it is close to 15, then suspect a parity or word length problem. If it is much shorter or longer, then look at a baud rate probelm (either from the PIC timings being wrong, or a setting at one end).
3) Unless you are _sure_ the defaults are correct, _specify_ the word length, and parity for your RS232. Both at the PIC, and in the terminal program, and make sure they match.

A couple of 'comments'. Get rid of *=16. This is for _16_ chips. Also get rid of BRG10K. This is for a couple of chips that have faults in the BRG handling. Theseshouldn't cause a problem, but are pointless. Add ERRORS to the serial declaration. At present, if more than one character arrives in the time round the loop (31 byte times), it'll cause the receive UART to hang. Why have a stream name, and use it 'part' of the time, then use STDIO for the rest of the time?. Either use streams, or don't use streams.


Best Wishes
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