2020-01-20 06:45 AM
Hey,
I have a project where I need to do a sequence of measurements and be able to select which test will be done. I'm using the stm32f469-discovery board and cubeMx/cubeIDE. Let's say I have ADC1 channel in use and input 1,2 and 3 in use for measurement 1. I have set up a scan mode conversion with DMA and it works nicely. Then I would like to do an other measurement which has to use the same ADC1 channel but this time input channels 4 and 5. It's not quite clear to me how can I select only these two channels since the adc settings have been set up for measurement 1. Is this even possible with cubeMX or do I have to do those settings in some other way?
Solved! Go to Solution.
2020-01-20 07:59 AM
You can perhaps use the injected conversion feature.
Each ADC controller supports two conversion sequences. There is the regular sequence, that's probably what you are using now, and there is the injected sequence.
The injected sequence can contain up to 4 channels, configured in the ADC->JSQR register. You can then start the injected sequence by setting ADC_CR2_JSWSTART, the regular sequence will be paused, the injected conversion results will be stored in ADC->JDR1 ... JDR4, and the ADC_SR_JEOC bit will set when the injected sequence is complete. Each channel gets its own data register, so the results can be read directly from the JDR registers, no need to use DMA.
I don't know how to set it up with Cube or HAL, but if the ADC is otherwise already running, using the registers above is straightforward.
2020-01-20 07:59 AM
You can perhaps use the injected conversion feature.
Each ADC controller supports two conversion sequences. There is the regular sequence, that's probably what you are using now, and there is the injected sequence.
The injected sequence can contain up to 4 channels, configured in the ADC->JSQR register. You can then start the injected sequence by setting ADC_CR2_JSWSTART, the regular sequence will be paused, the injected conversion results will be stored in ADC->JDR1 ... JDR4, and the ADC_SR_JEOC bit will set when the injected sequence is complete. Each channel gets its own data register, so the results can be read directly from the JDR registers, no need to use DMA.
I don't know how to set it up with Cube or HAL, but if the ADC is otherwise already running, using the registers above is straightforward.
2020-01-21 03:38 AM
Thank you! That worked.