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

Serial Communication on PIC18 series

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







Serial Communication on PIC18 series
PostPosted: Tue Dec 03, 2002 1:41 pm     Reply with quote

Hello,

I am trying to program PIC18 so that it can communicate with PC via RS-232. However, I am getting erroneous result. I use the very same code to do the same on PIC16 and it works just fine. I wonder if there is anything more I need to set to get it work properly on PIC18. Below is my code:

#include <18f458.h>
#fuses XT,NOWDT,NOPROTECT,PUT, NOLVP
#use delay(clock=4000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)

#ifndef SCL_LINE
#define SCL_LINE PIN_C3
#define SDA_LINE PIN_C4
#endif

#use i2c(master, sda=SDA_LINE, scl=SCL_LINE)

void main()
{
printf("testing");
}

The output on the screen on my PC is:

testitestestesteitstes

Any idea?
Thanks for help guys
___________________________
This message was ported from CCS's old forum
Original Post ID: 9736
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

Re: Serial Communication on PIC18 series
PostPosted: Tue Dec 03, 2002 1:53 pm     Reply with quote

:=Hello,
:=
:=I am trying to program PIC18 so that it can communicate with PC via RS-232. However, I am getting erroneous result. I use the very same code to do the same on PIC16 and it works just fine. I wonder if there is anything more I need to set to get it work properly on PIC18. Below is my code:
:=
:=#include <18f458.h>
:=#fuses XT,NOWDT,NOPROTECT,PUT, NOLVP
:=#use delay(clock=4000000)
:=#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
:=
:=void main()
:={
:=printf("testing");
:=}
:=
:=The output on the screen on my PC is:
:=
:=testitestestesteitstes
--------------------------------------------------
Your problem appears to be that it displays all but
the last 2 characters and then resets and does it again.

I notice that you don't have a "while(1);" statement
at the end of the program. This statement is necessary
to prevent the program from executing the hidden SLEEP
instruction that CCS puts at the end of main().

It could be that your PIC is going to sleep, and then
waking up for some reason, and re-starting. You should
add that statement.

___________________________
This message was ported from CCS's old forum
Original Post ID: 9738
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