Adc Code

  • Uploaded by: Ankit Daftery
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Adc Code as PDF for free.

More details

  • Words: 162
  • Pages: 1
void adc_init(void) { ADCSRA=0X00; flags ADMUX=0X60; ADCSRA=0X87; conversion, and the 128 ACSRA=0X80; }

// Function to initialise the ADC feature // Clear previous ADC results and status // 0x40 for 10 bits // We have set the ADSC bit to start a // ADPS bits are set so that the prescaler is // ADEN is set, to enable the ADC

unsigned char adc_start(unsigned char channel) // Function to perform an ADC conversion, Takes 0-8 as input // to select which input to convert { unsigned char i; ADCH=0x00; // Clear the previous result i=channel&0x07; conversion on ADMUX=i|0x60; the ADC control register ADCSRA|=1<
// Decide which line to perform ADC // Enter which line to perform in

// wait for conv. to complete //unsigned int temp=ADC; for 10

/* ---------------- Sample ADC Call -----------------------*/ unsigned char result=adc_start(0); Pin A0 and stores the result

// This performs ADC conversion on // to variable "result"

Related Documents

Adc Code
May 2020 5
Adc
July 2020 17
Adc
May 2020 18
Adc
August 2019 36
Adc Registers
May 2020 10
Dung Adc
May 2020 9

More Documents from ""