rpschultz13
Member
Hi,
I have some frequency detection code that works on Arduino Nano (AVR) using autocorrelation. I know that the ADC Sampling lines in the code below are for AVR chips (doesn't work on esp32), but I've read that it should work on Teensy 4.0. But it doesn't currently. I'm wondering if I need to include a library or something similar like that:
These lines error:
I have some frequency detection code that works on Arduino Nano (AVR) using autocorrelation. I know that the ADC Sampling lines in the code below are for AVR chips (doesn't work on esp32), but I've read that it should work on Teensy 4.0. But it doesn't currently. I'm wondering if I need to include a library or something similar like that:
These lines error:
Code:
//set up continuous sampling of analog pin 0
//clear ADCSRA and ADCSRB registers
ADCSRA = 0 ;
ADCSRB = 0 ;
ADMUX |= (1 << REFS0) ; //set reference voltage
ADMUX |= (1 << ADLAR) ; //left align the ADC value- so we can read highest 8 bits from ADCH register only
ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // ADC clock 128 prescaler- 16mHz/128=125kHz->9615 sps
ADCSRA |= (1 << ADATE); //enable auto trigger
ADCSRA |= (1 << ADIE) ; //enable interrupts when measurement complete
ADCSRA |= (1 << ADEN) ; //enable ADC
ADCSRA |= (1 << ADSC) ; //start ADC measurements
}
ISR(ADC_vect) { // When ADC sample ready, put in buffer if not full
if (sampleCnt < bufferSize)
{
rawData[sampleCnt] = ADCH ;
sampleCnt++ ;
}
}