PIC16F877A Code problems

From: Devyn (devyntt_at_yahoo.com)
Date: 03/30/04


Date: 30 Mar 2004 09:34:24 -0800

Greetings Everybody!

 I was trying to use the A/D module in PIC16F877A. I'm using a C
compiler (Hi-tech Picclite). The code i wrote passes values to PORTD.

The compiler declared the o/p of the ADC as ADRESH and ADRESL, "static
volatile unsigned char" type. The code I wrote was :-

char a,b;
//after adc conversion (which works)
//o/p right justified
a=ADRESH;
b=ADRESL;
PORTD=a; //works
PORTD=b; //doesnt work
PORTD=ADRESL; //works

What is happening? I suspected 'sign' problem, so i changed a,b to
"unsigned char", but the code still doesnt work. The register has MSB
= 1 usually (hence a sign problem?) Can anyone please help me out?

Thanks in Advance,
Devyn


Quantcast