Hi,
I have study the circuit of PR11 and C code fro PR11. Currently, I have 2 question for the sample C code that supply by Cytron for PR11;
1) Why we need to shift 8 bit. (refer to below c code, in red). Also what the meaning of c code below (green font).
void read_adc(void)
{
unsigned short i;
unsigned long result_temp=0;
for(i=2000;i>0;i-=1) //looping 2000 times for getting average value
{
ADGO = 1; //ADGO is the bit 2 of the ADCON0 register
while(ADGO==1); //ADC start, ADGO=0 after finish ADC progress
result=ADRESH;
result=result<<8; //shift to left for 8 bit
result=result|ADRESL; //10 bit result from ADC
result_temp+=result;
}
result = result_temp/2000; //getting average value
}
2) What are the function of below subroutine. I can't found in the C code, where we call this subroutine.
void increment(unsigned long data)
{
unsigned short j;
for(j=10;j>0;j--)
{ lcd_goto(32);
data=data+1;
dis_num(data);
delay(10000);
}
}
Thanks.