![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Diego Guest
|
PIC16f877 UART problem |
Posted: Tue Aug 30, 2005 11:16 am |
|
|
hello, sorry for my english...
I have a problem using the serial RX for the PIC16f877, the code will be captured and return a char send by the serial com of my pc; always the PIC send a 0x00. The same code with the PIC16f873 works 'ok'; Using Proteus works ok too. Thank's for your help. The code is:
#include <16F877A.h>
#device adc=8
#FUSES NOWDT //No Watch Dog Timer
#FUSES HS //High speed Osc (> 4mhz)
#FUSES NOPUT //No Power Up Timer
#FUSES NOPROTECT //Code not protected from reading
#FUSES NODEBUG //No Debug mode for ICD
#FUSES BROWNOUT //Reset when brownout detected
#FUSES NOLVP //Low Voltage Programming on B3(PIC16) or B5(PIC18)
#FUSES NOCPD //No EE protection
#FUSES NOWRT //Program memory not write protected
#use delay(clock=12000000)
#use rs232(baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,enable=PIN_C5)
#byte Port_B=6
#byte Port_A=5
#byte Port_C=7
#byte Port_D=8
#byte RCReg=0x1A
#byte RCSta=0x18
#byte PIR1=0x0C
#bit RCIF = 0x0C.5
char buffer;
#int_rda
Rda_ISR()
{
if(kbhit()){
buffer=getc();
putc(buffer);
}
}
void main()
{
setup_adc_ports(NO_ANALOGS);
setup_adc(ADC_OFF);
setup_timer_0(RTCC_INTERNAL|RTCC_DIV_1);
setup_counters(RTCC_INTERNAL,WDT_288MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
set_tris_c(0b11000000);
port_c=0;
enable_interrupts(INT_RDA);
printf("Inicio"); //this line works ok.
enable_interrupts(GLOBAL);
while(1){
restart_wdt();
}
} |
|
![](templates/subSilver/images/spacer.gif) |
MikeValencia
Joined: 04 Aug 2004 Posts: 238 Location: Chicago
|
|
Posted: Tue Aug 30, 2005 4:28 pm |
|
|
I've printf'ed several times from an '877 in the past. Try the code below. It works with a picdem-2 demo board hooked and Hyperterminal. (Actually this code is cut and pasted from an 18F458, and i don't have PCM, just PCH).
Code: |
#include <16F877.h>
#fuses HS,NOWDT,NOPROTECT,NOLVP,PUT
#use delay(clock=12000000)
#case
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, ERRORS)
#ignore_warnings 202
void main(void)
{
printf ("Hello World\r\n");
while(1);
}
|
|
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|