temp = channel << 3; // Shift channel value three bits left ADCON0 &= 0b11000111; // Clear channel select bits in ADCON0 ADCON0 |= temp; // Logically OR shifted channel value into place in ADCON0
ADGO = 1; // Initiate conversion on selected channel while (ADGO) ; // Poll ADGO bit until it clears, indicating conv. done AD_Int.AD_Byte.AD_MSB=ADRESH; AD_Int.AD_Byte.AD_LSB=ADRESL; }
temp = channel_1 << 3; // Shift channel value three bits left ADCON0 &= 0b11000111; // Clear channel select bits in ADCON0 ADCON0 |= temp; // Logically OR shifted channel value into place in ADCON0
ADGO = 1; // Initiate conversion on selected channel while (ADGO) ; // Poll ADGO bit until it clears, indicating conv. done AD_Int_1.AD_Byte_1.AD_MSB_1=ADRESH; AD_Int_1.AD_Byte_1.AD_LSB_1=ADRESL; }
temp = channel_2 << 3; // Shift channel value three bits left ADCON0 &= 0b11000111; // Clear channel select bits in ADCON0 ADCON0 |= temp; // Logically OR shifted channel value into place in ADCON0
ADGO = 1; // Initiate conversion on selected channel while (ADGO) ; // Poll ADGO bit until it clears, indicating conv. done AD_Int_2.AD_Byte_2.AD_MSB_2=ADRESH; AD_Int_2.AD_Byte_2.AD_LSB_2=ADRESL; }
//*************************************** //* Program Main ( ) * //*************************************** void main(void) { OpenLCD(); ADCON1=0b10000000; //all channel is A/D input and Right justified TRISA0=1; TRISA1=1; TRISA2=1; TRISA3=1; TRISA4=1; TRISA5=1; TRISE0=1; TRISE1=1; TRISE2=1; TRISC=0x00; // Set PortC for Output PORTC=0x80; // Initila LED display = 0x80
while(1) { A2D_0(0x00); // Get 10-bit A/D result from CH0 LCD_Set_Cursor(0,0); LCD_ItoA(AD_Int.AD_10bit); delay_x_ms(100); A2D_1(0x01); // Get 10-bit A/D result from CH1 LCD_Set_Cursor(6,0); LCD_ItoA(AD_Int_1.AD_10bit_1); delay_x_ms(100); A2D_2(0x02); // Get 10-bit A/D result from CH2 LCD_Set_Cursor(0,1); LCD_ItoA(AD_Int_2.AD_10bit_2); delay_x_ms(100);
}
}
void LCD_ItoA(unsigned int AD_Data) { AD_Temp=AD_Data; DS_Zero_Flag=1;