Skip to main content
Code formatting.
Source Link
Edgar Bonet
  • 45.2k
  • 4
  • 42
  • 81

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down.
I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me.
How can I achieve such thing? I am using arduino uno.

this is the code I have that sets up the ADC interrupt:

ADCSRA = 0;
ADCSRB = 0;
ADMUX = 0;
ADMUX |= (1 << REFS0) + (1 << REFS1);
ADMUX |= (1 << ADLAR);

ADCSRA |= (1 << ADATE); //enabble auto trigger
ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
ADCSRA |= (1 << ADEN); //enable ADC
ADCSRA |= (1 << ADSC);
ADCSRA |= 0b010;

ISR(ADC_vect) {//when new ADC value ready af = af + ADCH; aaf++; }

  ADCSRA = 0;  
  ADCSRB = 0;  
  ADMUX = 0;  
  ADMUX |= (1 << REFS0) + (1 << REFS1);  
  ADMUX |= (1 << ADLAR);  

  ADCSRA |= (1 << ADATE); //enabble auto trigger  
  ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete  
  ADCSRA |= (1 << ADEN); //enable ADC  
  ADCSRA |= (1 << ADSC);  
  ADCSRA |= 0b010;  
  
ISR(ADC_vect) {//when new ADC value ready
  af = af + ADCH;
  aaf++;
}

I found this on the internet, but it didn't work as I expected.

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down.
I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me.
How can I achieve such thing? I am using arduino uno.

this is the code I have that sets up the ADC interrupt:

ADCSRA = 0;
ADCSRB = 0;
ADMUX = 0;
ADMUX |= (1 << REFS0) + (1 << REFS1);
ADMUX |= (1 << ADLAR);

ADCSRA |= (1 << ADATE); //enabble auto trigger
ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
ADCSRA |= (1 << ADEN); //enable ADC
ADCSRA |= (1 << ADSC);
ADCSRA |= 0b010;

ISR(ADC_vect) {//when new ADC value ready af = af + ADCH; aaf++; }

I found this on the internet, but it didn't work as I expected.

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down.
I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me.
How can I achieve such thing? I am using arduino uno.

this is the code I have that sets up the ADC interrupt:

  ADCSRA = 0;  
  ADCSRB = 0;  
  ADMUX = 0;  
  ADMUX |= (1 << REFS0) + (1 << REFS1);  
  ADMUX |= (1 << ADLAR);  

  ADCSRA |= (1 << ADATE); //enabble auto trigger  
  ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete  
  ADCSRA |= (1 << ADEN); //enable ADC  
  ADCSRA |= (1 << ADSC);  
  ADCSRA |= 0b010;  
  
ISR(ADC_vect) {//when new ADC value ready
  af = af + ADCH;
  aaf++;
}

I found this on the internet, but it didn't work as I expected.

more details added
Source Link
aky-her
  • 103
  • 1
  • 5

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down. 
I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me. 
How can I achieve such thing? I am using arduino uno.

this is the code I have that sets up the ADC interrupt:

ADCSRA = 0;
ADCSRB = 0;
ADMUX = 0;
ADMUX |= (1 << REFS0) + (1 << REFS1);
ADMUX |= (1 << ADLAR);

ADCSRA |= (1 << ADATE); //enabble auto trigger
ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
ADCSRA |= (1 << ADEN); //enable ADC
ADCSRA |= (1 << ADSC);
ADCSRA |= 0b010;

ISR(ADC_vect) {//when new ADC value ready af = af + ADCH; aaf++; }

I found this on the internet, but it didn't work as I expected.

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down. I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me. How can I achieve such thing? I am using arduino uno.

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down. 
I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me. 
How can I achieve such thing? I am using arduino uno.

this is the code I have that sets up the ADC interrupt:

ADCSRA = 0;
ADCSRB = 0;
ADMUX = 0;
ADMUX |= (1 << REFS0) + (1 << REFS1);
ADMUX |= (1 << ADLAR);

ADCSRA |= (1 << ADATE); //enabble auto trigger
ADCSRA |= (1 << ADIE); //enable interrupts when measurement complete
ADCSRA |= (1 << ADEN); //enable ADC
ADCSRA |= (1 << ADSC);
ADCSRA |= 0b010;

ISR(ADC_vect) {//when new ADC value ready af = af + ADCH; aaf++; }

I found this on the internet, but it didn't work as I expected.

more details added
Source Link
aky-her
  • 103
  • 1
  • 5

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down. I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me. I could How How can I achieve such thing? I am using arduino uno.

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready. I tried to look into the datasheet, but it's too complicated for me. I could How can I achieve such thing? I am using arduino uno.

I have a microphone and I need as precise values as possible. I have been told by my teacher, that it is somehow possible to make a ADC timer interrupt, which would interrupt always when the value is ready, so that the reading itself would not slow the program down. I know, how to use timer interrupts to read the analog value every other ms or something and I even have a code that lets the ADC read automaticly and takes the value, but I need to make it take the value always when it's ready, so that I would have every value the ADC read. I tried to look into the datasheet, but it's too complicated for me. How can I achieve such thing? I am using arduino uno.

Source Link
aky-her
  • 103
  • 1
  • 5
Loading