Pitch perfect audio on Arduino Micro

Thanks for posting that code, I can see where you are going wrong.
The whole point about using the A/D in free running mode is that you can use the time normally spent waiting for a conversion to finish to do something else. What you have done here is to still use an analogRead() to get a sample. That function starts off a conversion and waits until it has finished, so it is not taking any advantage of you earlier putting it into free running mode.

When you are in free running mode you can use it in one of two ways.

  1. Check that the EOC end of conversion flag has been set and then read the two results registers.
  2. Enable the EOC flag to generate an interrupt and have the ISR for that vector read the two results registers.

Correct it is not what I mean.
If you look at the data sheet for the Arduino Micro's processor (ATmega 32u4) Download the complete data sheet from here Section 9.1 contains a list of the interrupt vectors

Vector number 30 is the one for "ADC Conversion Complete" This is the one where you put the address of the ISR to run when the free running A/D has been set and you want an ISR to just read the A/D registers. It is in this ISR that you can enable the global interrupts again if you want so that other sources of interrupt can get a look in and interrupt your interrupt routine. You do not do this in "normal" code.

1 Like