View previous topic :: View next topic |
Author |
Message |
attabros
Joined: 28 Jul 2008 Posts: 35
|
RS232 problem |
Posted: Thu Sep 11, 2008 4:47 am |
|
|
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
|
Re: RS232 problem |
Posted: Thu Sep 11, 2008 5:35 am |
|
|
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
|
|
Posted: Thu Sep 11, 2008 6:34 am |
|
|
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
|
|
Posted: Thu Sep 11, 2008 8:19 am |
|
|
Change this:
Quote: | #FUSES XT //Crystal osc <= 4mhz |
to this:
#FUSES HS
and try again. _________________ David |
|
|
attabros
Joined: 28 Jul 2008 Posts: 35
|
|
Posted: Thu Sep 11, 2008 10:27 pm |
|
|
#fuses HS
it works THANKS |
|
|
|