![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Niko Guest
|
Serial Communication on PIC18 series |
Posted: Tue Dec 03, 2002 1:41 pm |
|
|
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 |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
Re: Serial Communication on PIC18 series |
Posted: Tue Dec 03, 2002 1:53 pm |
|
|
:=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 |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|