0% found this document useful (0 votes)
16 views1 page

Lab 6 Rtes 11

The document describes an experiment using an analog to digital converter. An input voltage from a potentiometer is given to an analog channel and converted to a 10-bit digital result, with the lower 8 bits displayed on one port and the upper 2 bits on another port.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views1 page

Lab 6 Rtes 11

The document describes an experiment using an analog to digital converter. An input voltage from a potentiometer is given to an analog channel and converted to a 10-bit digital result, with the lower 8 bits displayed on one port and the upper 2 bits on another port.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Real Time Embedded System Lab Department of Electrical & Computer Engineering

Lab 06- APPLICATION AND UNDERSTANDING OF ANALOG


TO DIGITAL CONVERTER
Task 01: Here an input signal of voltage from the potentiometer is given to analog input
channel AN0 then the 10-bit result after conversion has been displayed on 8 bits at PORTC and
remaining 2 bits PORTD.
Matlab Code:
\* File:   atdc.c
 * Author: Syed Haider Abbas
 * Created on October 24, 2022, 8:58 PM
 */
#pragma config OSC = HS
#pragma config WDT = OFF
#pragma config PWRT = OFF
#pragma config BOREN = OFF
#pragma config LVP = OFF
#pragma config CPD = OFF
#pragma config WRTD = OFF
#pragma config CP1 = OFF
#include <xc.h>
void delay(int n);
void main(void)
{
 TRISC=0x00;
 TRISD=0x00;
 TRISAbits.TRISA0=1;
 ADCON0=0x81;
 ADCON2=0xCE;
 while(1) {
 delay(1);
 ADCON0bits.GO=1;
while(ADCON0bits.DONE==1)
 PORTC=ADRESL;
 PORTD=ADRESH;
 delay(1);
 } }
void delay(int n)
{ for(int i=0;i<n;i++)
 { for(int j=0;j<250;j++) { }
 } }
Output:

Registration No: FA19-BSEE-023

You might also like