STM32G431RB — ADC1 Interrupt and ADC2 DMA (7 Channels) with FreeRTOS — External Voltage Detection
Hello,
I am working on STM32 NUCLEO-G431RB using STM32CubeIDE and FreeRTOS (CMSIS-RTOS v2).
I am trying to implement the following requirement:
Requirement
- ADC1 → 1 Channel using Interrupt
- ADC2 → 7 Channels using DMA
- Both should run simultaneously with FreeRTOS
ADC Configuration
ADC1 (Interrupt)
- Single channel (PA0)
- Using HAL_ADC_Start_IT()
- Used for detecting external voltage
Expected Behavior:
- When I connect external power supply to PA0
- PA0 should show voltage value
- Remaining 7 channels should show 0
Example:
PA1 = 0
PA6 = 0
PA7 = 0
PC0 = 0
PC1 = 0
PC2 = 0
PC3 = 0
ADC2 (DMA)
7 Channels:
- PA1
- PA6
- PA7
- PC0
- PC1
- PC2
- PC3
Configuration:
- Scan conversion enabled
- Continuous conversion enabled
- DMA circular mode
- Using HAL_ADC_Start_DMA()
Expected Behavior:
If I connect external voltage to PA1
PA1 = 2.5V (DMA)
PA6 = 0
PA7 = 0
PC0 = 0
PC1 = 0
PC2 = 0
PC3 = 0
Similarly, if I connect external voltage to any ADC pin, only that pin should show voltage and others should show 0.
FreeRTOS
I am using:
- ADC interrupt callback
- DMA complete callback
- FreeRTOS task
- Semaphore for synchronization
My Questions
- Is it correct to use ADC1 Interrupt + ADC2 DMA simultaneously?
- Is this recommended for STM32G431RB?
- Any issues when using FreeRTOS + ADC + DMA together?
- Is this the correct architecture for this requirement?
Hardware
Board: STM32 NUCLEO-G431RB
IDE: STM32CubeIDE
RTOS: FreeRTOS (CMSIS-RTOS v2)
External Power Supply: 0-3.3V analog input
Any suggestions or recommended approach would be very helpful.
Thank you.
