I try to modify resolution and averaging of ADC object but it fails
compiled as is generates:
which is OK
first number after loop is number of blocks retrieved from queue, the other two numbers are from PDB
However, compiled with #define STEP 1, that is with the additional code in setup() to modify ADC setup, the result becomes:
that is, no buffers are found on queue.
It seems that the call to the analog.c functions are not always handled correctly and crashed ADC operation.
Note, I have no problem with generating my own ADC object or use Pelvide's ADC library, but here I wanted to use Audio Library without modifications to the library.
Code:
/*
* Simple ADC test
*/
#include "input_adc.h"
#include "record_queue.h"
#define STEP 0
// GUItool: begin automatically generated code
AudioInputAnalog adc1; //xy=165,237
AudioRecordQueue queue1; //xy=348,308
AudioConnection patchCord1(adc1, queue1);
// GUItool: end automatically generated code
void setup() {
// put your setup code here, to run once:
AudioMemory (4);
while(!Serial);
Serial.println("Start");
#if (STEP ==1)
Serial.println("change1");
analogReadRes(10);
analogReference(INTERNAL); // range 0 to 1.2 volts
analogReadAveraging(1);
#endif
queue1.begin();
}
void loop() {
// put your main code here, to run repeatedly:
static uint32_t count=0;
if(queue1.available())
{ // fetch data from queue
int16_t * data =queue1.readBuffer();
queue1.freeBuffer();
count++;
}
static uint32_t t0;
if(millis()>t0+1000)
{ Serial.printf("loop: ");
Serial.printf("%d %d %d\n",count, PDB0_CNT, PDB0_MOD);
t0=millis();
count=0;
}
}
compiled as is generates:
Code:
Start
loop: 199 163 1359
loop: 345 1119 1359
loop: 345 801 1359
loop: 345 476 1359
loop: 345 149 1359
loop: 345 1184 1359
loop: 345 895 1359
loop: 345 563 1359
loop: 345 220 1359
first number after loop is number of blocks retrieved from queue, the other two numbers are from PDB
However, compiled with #define STEP 1, that is with the additional code in setup() to modify ADC setup, the result becomes:
Code:
Start
change1
loop: 0 1342 1359
loop: 0 906 1359
loop: 0 570 1359
loop: 0 252 1359
loop: 0 1282 1359
loop: 0 980 1359
loop: 0 636 1359
loop: 0 304 1359
It seems that the call to the analog.c functions are not always handled correctly and crashed ADC operation.
Note, I have no problem with generating my own ADC object or use Pelvide's ADC library, but here I wanted to use Audio Library without modifications to the library.