Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 6 months ago.
Increasing ADC sample rate (NUCLEO-F401RE)
Can someone point me in the right direction on how to change the default ADC parameters in order to improve the sample rate of the ADC?
2 Answers
9 years, 4 months ago.
Hi Matti, could you post the code you used to drop it down to 700ns?
Try this: ADC1->CR2 |= ADC_CR2_SWSTART; while (!(ADC1->SR & ADC_SR_EOC)); intPixelValue[intPixelIndex] = ADC1->DR; Read value of VIDEO, store in array
You can still initialize the ADC using the mbed library: AnalogIn analog_value(A2); PA4 - VIDEO first adc read takes a bit longer, value is not stored.. analog_value.read();
posted by 21 Jul 20159 years, 1 month ago.
Hi,
interesting discussion... I've tried this approach on my NUCLEO-L053R8. It's not an F401, but using the single conversion sequence code example from the STM32L053R8T6 MCU Reference Manual (Appendix 8.5) seems working fine.
I'm now trying to understand how to exploit the continuous mode conversion fully in HW. Code examples (A.8.6), after the init steps, relies on the use of these APIs:
/* Configure NVIC for ADC */ /* (1) Enable Interrupt on ADC */ /* (2) Set priority for ADC */ NVIC_EnableIRQ(ADC1_COMP_IRQn); /* (1) */ NVIC_SetPriority(ADC1_COMP_IRQn,0); /* (2) */
but it isn't clear to me how these could be integrated in the mbed development framework, for easy interrupt handling.
Also, a polling approach would be preferrable, I think, for a faster handling of data transfer, compared to interrupt handling. E.g. checking the EOSEQ (end of sequence) flag. But I wonder why this approach is not suggested in the code examples.
Anyone here who can help me?
thanks Fabio
Worked it out, the default ADC settings were fast enough.. Using read() takes roughly 3.5us, alot of this is caused by the abstraction framework and converting the result to a float. Accessing the hardware directly reduces the read time to 700ns. (200ns for conversion and 500ns for copying the result out of ADC1->DR...
posted by Matti Winther 10 May 2015