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

RS232 problem

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



Joined: 28 Jul 2008
Posts: 35

View user's profile Send private message

RS232 problem
PostPosted: Thu Sep 11, 2008 4:47 am     Reply with quote

Hi
I m tring to send data from controller to PC using PIC16F877A
& MAX232 firt i try just by sending "hello world" to PC using hyper
terminal,
I made the following code but dit does not work.

Code:


#include <16F877A.h>
#device adc=8

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES XT                       //Crystal osc <= 4mhz
#FUSES PUT                      //Power Up Timer
#FUSES NOPROTECT                //Code not protected from reading
#FUSES NODEBUG                  //No Debug mode for ICD
#FUSES NOBROWNOUT               //No brownout reset
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection
#FUSES NOWRT                    //Program memory not write protected

#use delay(clock=20000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)

void main()
{

   setup_adc_ports(NO_ANALOGS);
   setup_adc(ADC_OFF);
   setup_psp(PSP_DISABLED);
   setup_spi(FALSE);
   setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
   setup_timer_1(T1_DISABLED);
   setup_timer_2(T2_DISABLED,0,1);
   setup_comparator(NC_NC_NC_NC);
   setup_vref(FALSE);

   // TODO: USER CODE!!
while (TRUE)
{
     
     printf("Hello World: \r\n");
   
     delay_ms(1000);
     
}}



is the code correct if not what will be the other possibilities to make it work
i have checked the hardware connections
i connect PIN 25 (TX) of controller to PIN 11 of MAX, PIN26 (RX) of
controller to PIN 12 of MAX on the other side on RS232 connector PIN 2 to 14 of MAX & PIN 3 to 13 of MAX & PIUN 5 ground.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: RS232 problem
PostPosted: Thu Sep 11, 2008 5:35 am     Reply with quote

What do you see on pin RC7 when you look at it with a scope?
_________________
Robert Scott
Real-Time Specialties
Embedded Systems Consulting
MicroManiac



Joined: 21 Aug 2008
Posts: 34

View user's profile Send private message Send e-mail MSN Messenger

PostPosted: Thu Sep 11, 2008 6:34 am     Reply with quote

What clock are you using???
i noticed that you are using an XT clock which should be less then 4Mhz
but in the code you are using #use delay(clock=20000000)
This will not work if you are using XT clock
Try it and let me know
_________________
"Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction."
Albert Einstein
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Thu Sep 11, 2008 8:19 am     Reply with quote

Change this:
Quote:
#FUSES XT //Crystal osc <= 4mhz


to this:
#FUSES HS

and try again.
_________________
David
attabros



Joined: 28 Jul 2008
Posts: 35

View user's profile Send private message

PostPosted: Thu Sep 11, 2008 10:27 pm     Reply with quote

#fuses HS

it works THANKS
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