In: Electrical Engineering
Write an instruction sequence to configure the A/D converter of
the PIC18F452 to operate with the following parameters:
Conversion result right justified
fosc=32 MHz
Highest ambient temperature may reach 600oC
Use VDD and VSS as the high and low reference voltages
Convert channel AN0
Enable A/D Module
#include <p18f4620.h>
#include <UF_LCD.h>
#pragma config OSC = INTIO67
#pragma config WDT = OFF
#pragma config LVP = OFF
void main(void){
int adc_result;
OSCCON = 0xF6;
ADCON1 = 0x0F;
lcd_init();
ADCON0 = 0x11;
ADCON2 = 0x88;
lcd_char('0');
lcd_char('x');
while (42){
ADCON1 = 0x0A;
ADCON0 |= 0x02;
while (ADCON0bits.GO == 1);
adc_result = ADRES;
ADCON1 = 0x0F;
lcd_byte((adc_result >> 8) & 0x03);
lcd_byte(adc_result & 0xFF);
lcd_command(0x82);
}
}