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

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







RS232
PostPosted: Sun Jun 06, 2004 2:53 pm     Reply with quote

DOES ANYONE KNOW HOW TO SETUP THE HYPERTERMINAL
TO ACCEPT CHARCTERS FROM A PIC.

I AM USING WINDOWS XP

------------------------------------------------------------------------

WILL THE FOLLOWING CODE BE SUFFICENT FOR A BASIC TEST

Code:

#if defined(__PCM__) //compiler version control
#include <16F874.h> //PIC header file
#device ICD=TRUE // used for ICD programmer
#fuses XT,NOWDT,NOPROTECT,NOLVP,PUT,NOBROWNOUT //used for PIC configuraion
#use delay(clock=4000000) //used for built-in delay functions
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif


void main(void)
{

putc('*');


}


thank you
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 06, 2004 3:16 pm     Reply with quote

Quote:
DOES ANYONE KNOW HOW TO SETUP THE HYPERTERMINAL
TO ACCEPT CHARCTERS FROM A PIC. I AM USING WINDOWS XP


This thread contains instructions on how to setup Hyperterminal:
http://www.ccsinfo.com/forum/viewtopic.php?t=9253&highlight=hyperterminal

Your program should work, but you should add a while(1)
statement at the end of main(), to prevent the PIC from
going to sleep after it runs off the end of the program.
(If it did so, you would not even see the * character displayed).

Also, I would add a few more putc statements, (or a printf)
so you could see a few more chars. In a test program, it's
always best to make everything be very obvious. Don't
make things be so minimal that you could fail to see if
a program is really working.

void main(void)
{

putc('*');

while(1); // Add this line.
}


Also, does your demo board have a MAX232 (or equivalent)
level converter chip on it for the RS232 signals ? I hope so.
dpmohne



Joined: 27 May 2004
Posts: 9

View user's profile Send private message MSN Messenger

Re: RS232
PostPosted: Sun Jun 06, 2004 3:33 pm     Reply with quote

Quote:

Code:

#use delay(clock=4000000) //used for built-in delay functions
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7)
#endif




Another thing to note is that 4mhz won't support 9600baud

Duane
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Sun Jun 06, 2004 3:45 pm     Reply with quote

Quote:
Another thing to note is that 4mhz won't support 9600baud

Actually, it will. Look at this table in the 16F877 data sheet:

Code:
TABLE 10-4: BAUD RATES FOR ASYNCHRONOUS MODE (BRGH = 1)

FOSC = 4 MHz

BAUD                                 SPBRG
RATE                      %          value
(K)        KBAUD        ERROR     (decimal)
9.6        9.615        0.16          25
Simon
Guest







Baud rate
PostPosted: Sun Jun 06, 2004 3:47 pm     Reply with quote

Dmohne - What baud rate is best for a 4Mhz XTAL.

Any formuals/references??
Steve H.
Guest







PostPosted: Sun Jun 06, 2004 4:18 pm     Reply with quote

Simon: The info on USART speeds is in the USART section of the data sheet. You should read these few pages to get a better understanding of how the device works.

Steve H.
dpmohne



Joined: 27 May 2004
Posts: 9

View user's profile Send private message MSN Messenger

PostPosted: Mon Jun 07, 2004 1:30 pm     Reply with quote

PCM programmer wrote:

Actually, it will. Look at this table in the 16F877 data sheet:


Serves me right for not looking at the datasheet and just going off what I was told.
falleaf



Joined: 23 May 2004
Posts: 48

View user's profile Send private message

PostPosted: Thu Jun 24, 2004 4:15 pm     Reply with quote

Quote:
Another thing to note is that 4mhz won't support 9600baud

Duane


Oh, I can communicate with PC using 16f876 and 16f877 at 4Mhz osc at 9600 baud. it's oki.
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