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

rs232 on 18f4520

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







rs232 on 18f4520
PostPosted: Tue Nov 18, 2008 4:02 pm     Reply with quote

Hi, looking for some pointers / things to check with a problem I have.
I'm running rs232 via max3232 on and 18f4520.
I have a basic program running, and can send from the pic to hyper-terminal (windows).
When I try and send something back from hyper-terminal, then return it via the pic to ensure both tx and rx work, I get hieroglyphics back... i.e, when I send a key press from the keyboard back to the pic, I used getc command, assign data to a char, then do a printf, and get junk back at the hyper terminal.

any ideas?

thanks

james
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Tue Nov 18, 2008 4:14 pm     Reply with quote

Try a simple test program, as shown below. If your crystal is above
4 MHz, then change the fuse from XT to HS and also edit the #use delay
statement for the correct frequency.
Code:

#include <18F4520.H>
#fuses XT,NOWDT,PUT,BROWNOUT,NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)

//========================
void main()
{
int8 c;

printf("Start: \n\r");
 
while(1)
  {
   c = getc();
   putc(c);
  }   

}
james
Guest







PostPosted: Tue Nov 18, 2008 4:17 pm     Reply with quote

Thanks for your very quick reply,
I am unable to test anything until Thursday, am away from the workshop,

Thanks for your help so far and I will post again after I tried your suggestion.

Thank you again.

James
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Tue Nov 18, 2008 4:41 pm     Reply with quote

check the baud rate, number of start bits, data bits, stop bits and parity match. Most text type applications use 1 start, 1 stop, 8 data, no parity.

If you are using your own hardware then check that the max chip is generating the +10 and -10 volt levels. When the PIC is not transmitting you should be able to measure -10 volts on the transmit output from the MAX chip to the PC
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
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