Free Running ADC

I'm working on a project to measure sound frequencies and I'm trying to measure up to 44 kHz. Right now I can only measure up to 900 Hz. I was researching ways to increase the sampling frequency and found this thread: Accessing ADFR value to set ADC as free-running? - Syntax & Programs - Arduino Forum

I'm a noob and can't figure out how to respond to the thread to ask questions (or maybe I can't because it's not my thread?), but I can't get the code they used to work. Here's the code:

volatile long adcbin;
volatile long cnt;

void setup()
 Serial.begin(115200);     //begin Serial comm

 adcbin = 0;    //accumulation bin
 cnt = 0;    //count variable

 ADMUX |= (1 << REFS0); // Set ADC reference to AVCC

 ADCSRA |= (1 << ADEN);  // Enable ADC
 ADCSRA |= (1 << ADATE); // Enable auto-triggering
 ADCSRA |= (1 << ADIE);  // Enable ADC Interrupt

 sei();                 // Enable Global Interrupts

 ADCSRA |= (1 << ADSC);  // Start A2D Conversions

void loop()
 delay(1000);        //Every second:

 ADCSRA &= ~(1 << ADSC);    //Stop ADC
 ADCSRA &= ~(1(ADCSRA,ADIE);    //Disable ADC interrupts

 Serial.print(adcbin,DEC);    //Print the sum of ADC values
 Serial.print(cnt,DEC);    //divided by the number of samples
 cnt = adcbin / cnt;        
 Serial.println(cnt,DEC);    //Gives you the average sample's ADC value

 cnt = 0;            //Re-initialize
 adcbin = 0;

 ADCSRA |= (1 << ADIE);    //Re-enable ADC interrupts and A2D conversions
 ADCSRA |= (1 << ADSC);

ISR(ADC_vect)            //ADC interrupt
 uint8_t high,low;

 low = ADCL;            //Make certain to read ADCL first, it locks the values
 high = ADCH;            //and ADCH releases them.

 aval = (high << 8) | low;

 /* for further brevity at cost of clarity

     aval = ADCL | (ADCH << 8);

 also seems to work        */

   adcbin = adcbin + aval;    //accumulate the ADC values
   cnt++;            //iterate the counter


When I try to verify it the arduino app tells me there's a problem with this line:

ADCSRA &= ~(1(ADCSRA,ADIE); //Disable ADC interrupts

and gives me this error message:

sketch_mar22b.ino: In function 'void loop()':
sketch_mar22b:30: error: '1' cannot be used as a function
sketch_mar22b:30: error: expected `)' before ';' token
sketch_mar22b.ino: In function 'void __vector_21()':
sketch_mar22b:52: error: 'aval' was not declared in this scope

I don't understand the code well enough yet to know how to fix this. Help?

Looks like a typographical error, which is explained by the original author:
"I've chopped up my code, removing the non-pertinent parts, to present what should give an average ADC value every second, but don't come knocking on my door if it breaks everything. I haven't tested it with all the omissions.

But I figured I'd include it anyway just in case it proves helpful to anyone (or if some gurus want to point out that I've done something horrendously wrong)."

Unfortunately I don't know off hand what they were trying to do with that messed-up syntax. All of the register definitions are in the datasheet (ATmega328P, for the UNO). You set the ADC clock prescale to get the sample rate and set some register flags to enable the free-running mode and enable the interrupt. There is a maximum sample rate for full resolution and you can use faster sample rates if you don't need all ten bits per sample.

I think they meant:

ADCSRA &= ~(1 << ADIE);

(assuming we believe the comment, of course - my guess is they patched together one version of the code that wasn’t using &= and a version that was.

You were right, thanks! There was also an issue where "aval" hadn't been declared, but I assumed it was a volatile long like the other variables and the code seems to work now.