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 problem

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







RS232 problem
PostPosted: Sat Apr 29, 2006 10:48 pm     Reply with quote

Code:
#include <16F777.h>
#fuses INTRC_IO, NOWDT, NOPROTECT
#use delay (clock = 8000000)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7)

void main()
{
setup_oscillator(OSC_8MHZ);
while(1)
{
   output_high(PIN_A0);
   delay_ms(1000);
   output_low(PIN_A0);
   delay_ms(1000);
   printf("Hello");

}
}


The code is pretty simple but it doesn't work. I put an LED on pin A0 and it blinks but the rs232 does not work. I don't see anything on the screen. I am using max232 chip. I don't know what is the problem. Maybe it is because of the internal osc?
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sat Apr 29, 2006 11:43 pm     Reply with quote

It looks like it should work. What's your compiler version ?

Are you using a demo board or did you make your own board ?
Freddie



Joined: 06 Sep 2003
Posts: 49

View user's profile Send private message

PostPosted: Sun Apr 30, 2006 6:39 am     Reply with quote

Here are some things that could help.
1) Double check that your Tx and Rx lines are connected correctly from the PIC to the MAX232 and from the MAX232 to the PC.

2) Make sure you have the correct port selected in your PC program.

3) If you are using Hyperterminal on the PC to capture/display the RS232 data, dont. That program has caused me many hours of frustration. Try this free program called TeraTermPro. It works great.
http://hp.vector.co.jp/authors/VA002416/teraterm.html


.
mmmm
Guest







PostPosted: Sun Apr 30, 2006 10:37 am     Reply with quote

i'm using version 3.202

Is it possible that it does not work because i'm using internal osc?
MMM2
Guest







PostPosted: Sun Apr 30, 2006 10:41 am     Reply with quote

btw, i'm using PIC16F777.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Apr 30, 2006 2:15 pm     Reply with quote

I tested your program with PCM vs. 3.202. It runs OK in the MPLAB
simulator, using UART1 for output. So that means the code is able
to fetch characters ("Hello") from a ROM table and put them in the
UART's Tx register. I looked at the .LST file and the UART setup
and transmit code looks OK. The setup code does incorrectly turn on
the A/D converter. CCS has a convention of putting in setup code
to disable it at start-up. But that bug doesn't affect UART operation.

If the OSCTUNE register was written to by code, it could change the
frequency of the internal oscillator, perhaps enough to cause errors
with the RS232. But I don't see anything in the .LST file that writes
to the OSCTUNE register.

So I think it's most likely that you have a hardware problem with
the connections to the MAX232 chip. The capacitors may not be
connected correctly, or the connections between the PIC and the
MAX232 may be incorrect, or between the PC and the MAX232.
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