How to increase sampling speed on Arduino Nano Every

I would like to port my oscilloscope code to Arduino Nano Every in order to take advantage of its higher clock speed, but changing the prescale setting does not work on Every because ADCSRA does not exist.
What code should replace this one:

#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))

void setup()
{
  Serial.begin(9600);
  pinMode(A5, INPUT);

  sbi(ADCSRA, ADPS2);
  cbi(ADCSRA, ADPS1);
  cbi(ADCSRA, ADPS0);
}

void loop()
{
  //and then use analogRead(A5);

Which higher clock speed? According to boards.txt it's 16 MHz

nona4809.build.f_cpu=16000000L

Arduino Nano Every claims having 20 MHz instead of 16. And I verified it is capable to execute analogRead() (without accelerators) in 82 microseconds instead of the 115 required by any of the other Arduinos (Uno, Nano, Mega).
Those platforms reach a seven time faster speed (17 microseconds) when unsing the accelerators I have shown. Had Nano Every be accelerated, it would perform analoRead() in about 12 microsecs...

You will really need to spend some time with the data sheet for the 4809.
There are two modes(free running and single conversion), two resolutions(8/10 bit) and interactions with Vref.

If you just want to modify the standard core for reading faster than 125KHz
check out this thread on how to set PRESCALER in ADC0.CTRLC
https://forum.arduino.cc/t/adc-register-nano-every/860146/12

1 Like

Thank you very much, although right now I'm organizing my holidays ;-)))

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.