ergen
Junior Member level 3
877 Newbie
Hi there,
I just upgrade my mcu's from 16F628 to 16F877A and i have lots of problems now.I even don't have an idea how to use it.Let me describe my project.It is so simple but i cant do it.I have a 16F877, max232, 2 leds, 4 caps (1uf), 2 ceramic caps (22 pf), an xtall (4mhz), 3 resistor (10Kohm, 2 * 220 ohm).I want to measure 0-5V voltages via pic and send them to computer.Let me to describe my circuit. I connected 10K res between Pin1 and +5V.I connected pin11,pin32 to +5V.I connected pin12,pin31 to GND.I connected green led (+)pin to pin38, (-)pin to res 220 ohm and other pin of res 220 ohm to gnd.I connected xtall between pin12 and pin13.I connected 22pf to xtall pin1 and other 22 pf cap to xtall pin 2, the other pins of caps to GND.I connected (+) red led pin to +5V, (-) pin to other res 220 ohm and other pin of res to GND.I connected a 1 uf cap between max-pin1(+) and max-pin 3(-).Another 1 uf cap between max-pin4(+) and max-pin5(-) and 1 uf cap between max-pin16(-) and max-pin2(+).1 uf cap between max-pin6(-) and max-pin15(+).I connected Max-pin(16) to +5V and Max-pin(15) to GND.Then i loaded this program to pic16F877A and i gave voltage and nothing happened.Even led connected to Pic-Pin38 didn't turn on ( So what is wrong with this? Code is shown below (i use ccs c compiler 3.155):
project.c :
#include "C:\WORK\Project.h"
void main() {
int value;
setup_adc_ports(A_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,WDT_18MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
printf("Sampling:");
set_adc_channel( 0 );
do {
delay_ms(100);
value = Read_ADC();
printf("\n\rValue: %2X ",value);
output_high(PIN_B5);
} while (TRUE);
}
project.h :
#include <16F877A.h>
#device adc=8
#use delay(clock=4000000)
#fuses HS,WDT
#use rs232( baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8 )
Hi there,
I just upgrade my mcu's from 16F628 to 16F877A and i have lots of problems now.I even don't have an idea how to use it.Let me describe my project.It is so simple but i cant do it.I have a 16F877, max232, 2 leds, 4 caps (1uf), 2 ceramic caps (22 pf), an xtall (4mhz), 3 resistor (10Kohm, 2 * 220 ohm).I want to measure 0-5V voltages via pic and send them to computer.Let me to describe my circuit. I connected 10K res between Pin1 and +5V.I connected pin11,pin32 to +5V.I connected pin12,pin31 to GND.I connected green led (+)pin to pin38, (-)pin to res 220 ohm and other pin of res 220 ohm to gnd.I connected xtall between pin12 and pin13.I connected 22pf to xtall pin1 and other 22 pf cap to xtall pin 2, the other pins of caps to GND.I connected (+) red led pin to +5V, (-) pin to other res 220 ohm and other pin of res to GND.I connected a 1 uf cap between max-pin1(+) and max-pin 3(-).Another 1 uf cap between max-pin4(+) and max-pin5(-) and 1 uf cap between max-pin16(-) and max-pin2(+).1 uf cap between max-pin6(-) and max-pin15(+).I connected Max-pin(16) to +5V and Max-pin(15) to GND.Then i loaded this program to pic16F877A and i gave voltage and nothing happened.Even led connected to Pic-Pin38 didn't turn on ( So what is wrong with this? Code is shown below (i use ccs c compiler 3.155):
project.c :
#include "C:\WORK\Project.h"
void main() {
int value;
setup_adc_ports(A_ANALOG);
setup_adc(ADC_CLOCK_INTERNAL);
setup_psp(PSP_DISABLED);
setup_spi(FALSE);
setup_counters(RTCC_INTERNAL,WDT_18MS);
setup_timer_1(T1_DISABLED);
setup_timer_2(T2_DISABLED,0,1);
setup_comparator(NC_NC_NC_NC);
setup_vref(FALSE);
printf("Sampling:");
set_adc_channel( 0 );
do {
delay_ms(100);
value = Read_ADC();
printf("\n\rValue: %2X ",value);
output_high(PIN_B5);
} while (TRUE);
}
project.h :
#include <16F877A.h>
#device adc=8
#use delay(clock=4000000)
#fuses HS,WDT
#use rs232( baud=9600,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8 )