coyoteboy
Newbie level 1
pic16f877 problem
Dear all, I'm hoping you can help me out a little here as I'm a tad confused. I've done a good bit of PIC work before but from a self-taught basis so sometimes I miss things that are obvious - hence questioning here!
I'm currently debugging a bit of hardware developed by someone else - I have
the code and the hardware in front of me and from my previous PIC work I'm
99% certain it should be working fine. Its coded in C and essentially boils
down to something that tests two ADC values and reports them over the
serial port. Using pins 3 and 4 (adc channels 1 and 2) the code goes:
setup_adc_ports(A_ANALOG);
setup_adc_(ADC_CLOCK_INTERNAL);
setup_comparator(NC_NC_NC_NC);
port_b_pullups(0x00);
set_adc_chennel(1);
result=read_adc();
Print some chars,
print the result,.
set_adc_channel(2);
result-read_adc();
Print some chars
print result
It does this, waits some time, does it again and then stops.
The strange output is that the ADC reading is somewhere around 17-25 for the
first "result" and then 5 or 6 for the second. The actual voltage monitored
on the pins is 0.441v and 0.12v respectively, steady to the third decimal
place. On the second run similar results are obtained but not always the same.
Changing the voltage (they are pressure sensors) to 0.580 seems to make zero
difference to the first reading but changing the second to a voltage of
0.2v reads around 11. Reducing the voltage on the pins to zero yields no
change in the first but 0 on the second. These voltages have been tested at
the actual pin-body joint of the processor so are the actual pin voltages.
Taking off the sensor daughtercard and pegging the either pin high using a 10K resistor to 5v causes readings of ~230 on both pins/adcs. Pegging it to 0v gives 0 on both pins/adcs.
Can one pin be blown without affecting the others? I've only ever had a
whole port blow before. I had considered the switchover time being too
short with no delay before read_adc but the same happens before the second
reading and that is "correct". I'm still thinking this latter item may be the problem but without reprogramming it with delays I have no way of testing that theory (going to take some getting the bits together and typing the code up from hardcopy, but I'll do it if i have to). I'm not sure what impedance the sensors are effectively when running, but when powered off they have a resistance of 230K.
Any hints appreciated!
Dear all, I'm hoping you can help me out a little here as I'm a tad confused. I've done a good bit of PIC work before but from a self-taught basis so sometimes I miss things that are obvious - hence questioning here!
I'm currently debugging a bit of hardware developed by someone else - I have
the code and the hardware in front of me and from my previous PIC work I'm
99% certain it should be working fine. Its coded in C and essentially boils
down to something that tests two ADC values and reports them over the
serial port. Using pins 3 and 4 (adc channels 1 and 2) the code goes:
setup_adc_ports(A_ANALOG);
setup_adc_(ADC_CLOCK_INTERNAL);
setup_comparator(NC_NC_NC_NC);
port_b_pullups(0x00);
set_adc_chennel(1);
result=read_adc();
Print some chars,
print the result,.
set_adc_channel(2);
result-read_adc();
Print some chars
print result
It does this, waits some time, does it again and then stops.
The strange output is that the ADC reading is somewhere around 17-25 for the
first "result" and then 5 or 6 for the second. The actual voltage monitored
on the pins is 0.441v and 0.12v respectively, steady to the third decimal
place. On the second run similar results are obtained but not always the same.
Changing the voltage (they are pressure sensors) to 0.580 seems to make zero
difference to the first reading but changing the second to a voltage of
0.2v reads around 11. Reducing the voltage on the pins to zero yields no
change in the first but 0 on the second. These voltages have been tested at
the actual pin-body joint of the processor so are the actual pin voltages.
Taking off the sensor daughtercard and pegging the either pin high using a 10K resistor to 5v causes readings of ~230 on both pins/adcs. Pegging it to 0v gives 0 on both pins/adcs.
Can one pin be blown without affecting the others? I've only ever had a
whole port blow before. I had considered the switchover time being too
short with no delay before read_adc but the same happens before the second
reading and that is "correct". I'm still thinking this latter item may be the problem but without reprogramming it with delays I have no way of testing that theory (going to take some getting the bits together and typing the code up from hardcopy, but I'll do it if i have to). I'm not sure what impedance the sensors are effectively when running, but when powered off they have a resistance of 230K.
Any hints appreciated!