Hi folks,
I am using Wiced feather STM32F205 for my project and I want to be able to acquire and reconstruct input signals upto 3Mhz (i.e sampling rate = 6MSPS).
I was able to implement kelu's code on dual ADC and attain a sampling rate of 1.8 MSPS. I was going through the code written by hathatch based on ADC class and I made the following modifications in his code with an aim to get a sampling rate of 6MSPS. I am very new to ADC coding so it would be really great to have your suggestions and feedback.
define BUFSIZE 390
int analogPin = PC5;
int p2=PA1;
int p3=PA2;
int ledPin = PA15;
uint16_t buffer[BUFSIZE] = { 0 };
boolean flag;
// Init ADC with analog pin
ADC.begin(analogPin,p2,p3);
//triple mode
ADC1->regs->CR1 |= 0X07 << 0;
//set the resolution
adc_set_resolution (uint32_t adc, uint32_t 8 )
// Set up FIFO holding ADC data
ADC.setBuffer(buffer, BUFSIZE);
// Set up interrupt callback
// Fired when the FIFO is full of samples
ADC.attachInterrupt(adc_interrupt);
// Set sample rate, possible value is in enum adc_smp_rate (adc.h)
// When speed up the sample rate, you may need to increase
// the buffer. Otherwise buffer overrun error will occur
ADC.setSampleRate(ADC_SMPR_1_5);
// Start ADC sampling
ADC.start();
}
void loop()
{
if (flag)
{
for (m=0;m<390;m++)
{
val[m]=adc_read();
}
for (m=0;m<390;m++)
{
Serial.println(val[m]);
}
flag=false;
}
Hi folks, I am using Wiced feather STM32F205 for my project and I want to be able to acquire and reconstruct input signals upto 3Mhz (i.e sampling rate = 6MSPS). I was able to implement kelu's code on dual ADC and attain a sampling rate of 1.8 MSPS. I was going through the code written by hathatch based on ADC class and I made the following modifications in his code with an aim to get a sampling rate of 6MSPS. I am very new to ADC coding so it would be really great to have your suggestions and feedback.
define BUFSIZE 390
int analogPin = PC5; int p2=PA1; int p3=PA2; int ledPin = PA15; uint16_t buffer[BUFSIZE] = { 0 }; boolean flag;
void adc_interrupt(void) { digitalWrite(ledPin, HIGH); digitalWrite(ledPin, LOW); flag=true;
// Continue sampling ADC.resume(); }
void setup() { pinMode(ledPin, OUTPUT);
// Init ADC with analog pin ADC.begin(analogPin,p2,p3);
//triple mode ADC1->regs->CR1 |= 0X07 << 0;
//set the resolution adc_set_resolution (uint32_t adc, uint32_t 8 )
// Set up FIFO holding ADC data ADC.setBuffer(buffer, BUFSIZE);
// Set up interrupt callback // Fired when the FIFO is full of samples ADC.attachInterrupt(adc_interrupt);
// Set sample rate, possible value is in enum adc_smp_rate (adc.h) // When speed up the sample rate, you may need to increase // the buffer. Otherwise buffer overrun error will occur ADC.setSampleRate(ADC_SMPR_1_5);
// Start ADC sampling ADC.start(); }
void loop() { if (flag) { for (m=0;m<390;m++) { val[m]=adc_read(); } for (m=0;m<390;m++) { Serial.println(val[m]); } flag=false; }
}