Write an instruction sequence to configure the A/D converter of the PIC18F452 to operate with the...

Free

50.1K

Verified Solution

Question

Electrical Engineering

Write an instruction sequence to configure the A/D converter ofthe 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

Answer & Explanation Solved by verified expert
4.0 Ratings (815 Votes)

#include

#include

#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);

}

}


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students