sarabgt
Newbie level 4
i am trying to convert voice signal into digital signal by adc of atmega16 and i am confused with its code i am interfacing microphone with atmega16..pls help me out.
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
can you post your code and explain what is your confusion exactly[/QUOTE
i am confused with set of adc registers..which one to initialize first and how..??
i am not able to start the conversion and then store it to a memory adderess using c..
cn u pls help me..??
//Program for ADC to read from channel 0 and show the 8 bit o/p on PORTB
#include<avr/io.h>
#include<util/delay.h>
void ADC_init(void);
unsigned int ADC_read(unsigned char);
// ------------------------------------------------
int main(void)
{
unsigned int value;
DDRB=0xFF;
DDRD=0x03;
ADC_init(); // Initialization of ADC
// ch=0;
while(1)
{
value=ADC_read(0);
PORTB=value;
_delay_ms(500);
}
}
//------------------------------------------------
void ADC_init(void) // Initialization of ADC
{
ADMUX=(1<<REFS0); // AVcc with external capacitor at AREF
ADCSRA=(1<<ADEN)|(1<<ADPS2)|(1<<ADPS1)|(1<<ADPS0);
// Enable ADC and set Prescaler division factor as 128
}
unsigned int ADC_read(unsigned char ch)
{
ch= ch & 0b00000111; // channel must be b/w 0 to 7
ADMUX |= ch; // selecting channel
ADCSRA|=(1<<ADSC); // start conversion
while(!(ADCSRA & (1<<ADIF))); // waiting for ADIF, conversion complete
ADCSRA|=(1<<ADIF); // clearing of ADIF, it is done by writing 1 to it
return (ADC);
}
The following references could be proved helpful.sarabgt said:i am confused with set of adc registers..which one to initialize first and how..??
To answer this question, someone has to know which memory are you talking about (RAM, EEPROM). Then the programming language (assembly, C).sarabgt said:can u please tell me c code for storing data on a memory address..i want to store the converted result on a memory address
sarabgt said:is it necessary to connect avcc pin to vcc every time?
AVCC is the supply voltage pin for Port A and the A/D Converter. It should be externally connected to VCC
, even if the ADC is not used. If the ADC is used, it should be connected to VCC
through a low-pass filter.
Yes this could also be a problem. Please take a look at page 221 of the datasheet (ADMUX register) to understand the AREF pin connection cases.sarabgt said:i have also connected AREF to ground..is it also a problem?