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

problem in sending hello world to hyperterminal

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



Joined: 08 Sep 2008
Posts: 1

View user's profile Send private message

problem in sending hello world to hyperterminal
PostPosted: Mon Sep 08, 2008 4:03 am     Reply with quote

hi all,

i'm now trying to send "hello world" from my 16f877a through max232 to my hyperterminal. before that i'm trying the coding in asm and picBasic. but i still fail to send anything to my hyperterminal. Does anyone here can help me on this by using CCS? i need the simple coding way to make it works so that i know whether is my hardware problem or my coding problem.

thanks.

my connection is as below.

DB9 RS232 16f877a

pin2 (RxD) ------ T2out

T2in ----------------- Tx/ RB6

pin3 (TxD) ------ R2in

R2out ---------------- Rx/ RB7
Ttelmah
Guest







PostPosted: Mon Sep 08, 2008 4:44 am     Reply with quote

First, keep your problems in one thread. Oherwise it results in loads on uneccessary thread titles all dealing with one thing...

You don't give the pin numbers you have used on the MAX232. You need:

DB9 Pin 2 (RXD) to MAX232 pin 7
MAX 232 pin 10 to PIC pin 25
DB9 pin 3 (TXD) to MAX232 pin 8
MAX232 pin 9 to PIC pin 26

MAX232 pin 16 to 5v
MAX232 pin 15 to 0v

5v to _all_ PIC Vdd connections
0v to all the PIC Vss connections

Capacitor from Vdd to Vss close to the PIC. 0.1uF ceramic.
Capacitor from Vdd to Vss close to the MAX232. 47uF.

Capacitor between pins 4, and 5 of the MAX232 (depends on what version MAX232 you have - say 1uF). Same between pins 1 and 3. One from pin 6 to 0v. Another from pin 2 to 5v (or 0v, but then needs at least a 20v voltage rating).

DB9 pin 5 to 0v.

Then the PIC needs a resistor from pin 1 to 5v (say 4K7R).

Crystal between pins 13, and pins 14 on the PIC. Say 8Mhz or something around here (4 to perhaps 20MHz). Capacitor from each of these pins to 0v, try 27pF.

5v supply to the board.

Then the most basic code:
Code:

#INCLUDE   <16F877A.H>
#FUSES      HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,WRT
//Change 'HS' here to 'XT' if using a 4MHz crystal
#USE DELAY(CLOCK=8000000)
//Change number here to match crystal used.

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);
   delay_ms(100);
   //Pause to allow the Maxim charge pump to get going
   putc("Hello World\n\r");

   while (TRUE) ;   
}

Now, this is as basic as it is possible to go. If you can't get even this to work, you need to find somebody to actually show you what to do. We can't get much simpler...

Best Wishes
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Mon Sep 08, 2008 1:17 pm     Reply with quote

There are many ways to mess up what appears to be the simple task of sending a message via RS232 to a PC. Ttelmah advice is strong in insisting that the PIC side be kept as simple as possible. The choice of hyperterminal on the PC side often contributes to confusion. Hyperterm has many surprises ( free features) for the inexperienced to hang up on. Use CCS's SIOW or terraterm for clearer results if you can.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Mon Sep 08, 2008 4:32 pm     Reply with quote

I would slightly modify the code ttelmah supplied:
Code:
#INCLUDE   <16F877A.H>
#FUSES      HS,NOWDT,NOPROTECT,PUT,BROWNOUT,NOLVP,NOCPD,WRT
//Change 'HS' here to 'XT' if using a 4MHz crystal
#USE DELAY(CLOCK=8000000)
//Change number here to match crystal used.

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);
   
   while (TRUE) {
      delay_ms(100);
      putc("Hello World\n\r");
   }
}

This way it keeps sending while you play with the PC or wires.
_________________
The search for better is endless. Instead simply find very good and get the job done.
Guest








PostPosted: Tue Sep 09, 2008 12:13 am     Reply with quote

hi all,

Thanks for the reply. When I try it by using a 4Mhz OSC it works. But when I change the OSC to 20Mhz it doesnt work. When I change the value of the OSC to 20 Mhz I also changed the code as below.
Code:
#fuses HS,NOWDT,NOPROTECT,BROWNOUT,PUT,NOLVP

#use delay(clock=20000000)

But it seems like not working. I can't get anything from the hyperterminal.

thanks.
Ttelmah
Guest







PostPosted: Tue Sep 09, 2008 2:41 am     Reply with quote

You say 'OSC'. Presumably you mean _crystal_?. A crystal, is not an oscillator, without other parts. It is an important distinction, since you can have complete 'oscillators' in a package, and these need different wiring, and fuses.
Now, what is the specified loading capacitance for your 20MHz crystal?. Do you have any data on it at all?. Is it series of parallel resonant?. What is it's ESR?. Shunt capacitance?. How is the board laid out?. Getting the oscillator to run at all, is harder at higher frequencies. My 'guess' is that you are working on some sort of breadboard, and the stray capacitances are so high, that the 20MHz part just won't oscillate. It may be possible to get it to oscillate, but doing so, needs _data_.

Best Wishes
Guest








PostPosted: Tue Sep 09, 2008 7:30 pm     Reply with quote

Hi Ttelmah,

Sorry for my wording. I'm using a 20Mhz XTAL. It just a very simple two legs XTAL. Without datasheet. I connect 1 leg to Pin13 of PIC and another leg to Pin14 of PIC. And then both legs connect to each 22pF no polarity capacitor, and both legs of cap to ground.

What should I do to let the XTAL run ?

Thank you.
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