Assignment Number 2 MPI
Assignment Number 2 MPI
Fall 2019
Target CLO Evaluation: CLO2-C4
Assignment No. 2
Class: BCE- 5 Submission Date: 1-12-19 Total Marks: 10 Marks
Q#1
• Clear ADIF
• Set ADIE
• Set PEIE
• Set GIE
4. Start conversion
7. For next conversion, go to step 1 or step 2 as required. A/D conversion time per bit is
defined as TAD.
Program:
#include <pic.h>
#include"delay.h"
void ADC_Init()
int val;
ADCON0 = 0x81 | channel << 3;// channel selection SET THE CHANNEL
NUMBER
DelayUs(50);
continue;
val = ADRESH;
val = val<<8 | ADRESL;// combining the both adresh and adresl values to a
single variable
return (val);
void main()
TRISD=0X00;
PORTD=0X00;
ADC_Init();// adcintialising
while(1)// loop for ever
adcval=read_adc(0);
PORTD=0XFF; //setting the port value as high if adc value greater than
500
PORTD=0X00;
}
}
}
c) Display the digital data on output varying with Analog input variations.
Deliverables:
I) Interfacing Circuit Diagram
II) Code
III) Analog and Digital signals comparison figures on each input.
IV) Calculation of Analog to Digital Conversion