Changing the analog read prescale factor on the Arduino Nano 33 BLE

I am wondering how you change the analog prescale factor on the the Arduino nano 33 BLE. I have seen this method of speeding up analog read many places but it doesn't seem to work on the 33 BLE.

Code:
const int mic1Pin = A0;
int time1 = 0;
int time2 = 0;
int mic = 0;

#define cbi (sfr, bit) (SFR BYTE(sfr) &= BV(bit))
#define sbi (sfr, bit) (SFR BYTE(sfr) |= BV(bit))
void setup() {
Serial.begin(115200);

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

void loop() {
time1 = micros();
for (int i = 0; i < 100000; i ++)
{
mic = analogRead(A0);
}
time2 = micros();
Serial.println((time2 - time1) / 100000);
}

Error:
sketch_mar27b:13:17: error: 'ADPS0' was not declared in this scope

if i use this code instead to change the prescale factor it complies but does not increase the sampling rate

#if defined(ADCSRA)

cbi(ADCSRA, ADPS2);

cbi(ADCSRA, ADPS1);

sbi(ADCSRA, ADPS0);

#endif

The processor in the Nano Ble is an nRF52840.

Here's a link to the data sheet.

There is also a section on this forum for the new Nano boards
https://forum.arduino.cc/index.php?board=135.0
You can ask a moderator to move this posting there.

You may do better search on the Nordic site for questions about analog conversion rates than here.
https://devzone.nordicsemi.com/

Have at it, and let us know what you come up with.

I was able to get the sampling time down to 20us using this code in setup

nrf_saadc_acqtime_t acqTime = NRF_SAADC_ACQTIME_3US;
adcCurrentConfig.acq_time = acqTime;
analogUpdate();

unfortunately this isn't much better than the 20us that it normally gets and i'm a little confused because its saying that the acquire time is 3us and i'm assuming that the for loop does not take 17us so i'm not sure where the delay is taking place.

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