Guest
|
Help PIC16F877A e RS232 and radio CAT |
Posted: Fri Feb 05, 2010 1:02 pm |
|
|
Basically I think that the PIC is connected to the RS232 cat radio
but did not send the command PUTS. Hello on LCD is regularly written.
Maybe it takes RS232 interrupt, or maybe not enter in the while loop?
The simulation is all ok, it works perfectly. Any suggestions?
Thanks
Jo
Code: |
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed 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=10000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8)
#include <LCD.C>
#include <string.h>
#include <stdlib.h>
char pc[6];
char pcc[6];
char pcc1[5];
char pcc2[]="PC";
int16 WATTS;
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);
lcd_init();
lcd_gotoxy(5,1);
printf(lcd_putc "Hello ");
while(true)
{
puts("PC;");
gets(pc);
pcc[0]=pc[0];
pcc[1]=pc[1];
if(!strcmp(pcc,pcc2));
{
pcc1[0]=pc[2];
pcc1[1]=pc[3];
pcc1[2]=pc[4];
pcc1[3]=0;
WATTS=atol(pcc1);
lcd_gotoxy(9,2);
printf(lcd_putc,"%lu",WATTS);
delay_ms(1000);
printf(lcd_putc "\f");
}
}
}
|
|
|