Changing the ADC Prescaler on an Arduino MKR ZERO

Hi,

I'm trying to do a school project where I sample signals and apply a matched filter to them to detect certain signals. I've analysed the signal I want to detect and found out I'll need a sampling frequency of about 34 kHz to detect it properly (Nyquist sampling theorem). I'm using an MKR ZERO, mainly because of its higher amounts of SRAM (32 kb) and a faster clock (48 MHz).

The issue I'm having at the moment is that even with the faster clock, the MKR can only do about 29,000 ADC conversions per second. I've seen that people can change the prescaler on the ADC so that you can effectively increase the maximum rate you can sample at. I've tried to implement some code I've found online (https://forum.arduino.cc/index.php?topic=530905.0), but can't work out how to edit ADCRA.

Is there a library I can import? Or someway to adjust the values to change the prescaler?

Thank you for any help at all, even better if it shows I'm completely wrong in the first place lol

Luke

That guide is specific to AVR microcontrollers, where ADCSRA (ADc Control and Status Register A) is the name for the register that controls various parameters of the ADC.

The MKR Zero is based on a SAM microcontroller. You will need to consult the datasheet for the microcontroller and/or find a guide for the same thing on the Zero boards to find out what the analogous register is called and how to configure it.

Ah yes, probably should have worked that one out myself.

Did a quick google and found a library that you can use to implement things like the ADC prescalers on GitHub:

https://github.com/Molorius/ATSAMD21-ADC/blob/master/README.md

Hopefully helps someone else!