View previous topic :: View next topic |
Author |
Message |
Simon Guest
|
RS232 |
Posted: Sun Jun 06, 2004 2:53 pm |
|
|
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
|
|
Posted: Sun Jun 06, 2004 3:16 pm |
|
|
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
|
Re: RS232 |
Posted: Sun Jun 06, 2004 3:33 pm |
|
|
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
|
|
Posted: Sun Jun 06, 2004 3:45 pm |
|
|
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 |
Posted: Sun Jun 06, 2004 3:47 pm |
|
|
Dmohne - What baud rate is best for a 4Mhz XTAL.
Any formuals/references?? |
|
|
Steve H. Guest
|
|
Posted: Sun Jun 06, 2004 4:18 pm |
|
|
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
|
|
Posted: Mon Jun 07, 2004 1:30 pm |
|
|
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
|
|
Posted: Thu Jun 24, 2004 4:15 pm |
|
|
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. |
|
|
|