DMA to read multiple ADC Channels
I am trying to read multiple ADCs using DMA on a Nucleo H743ZI2. I currently have code that works, but it only works when my data buffer has a size of 32. This is fine when I was using two channels, but any more than that, it offsets the data, and I cannot know what index is what ADC Channel. If I change the size of the data buffer, then the code stops working the second I try and do anything other than assign variables. I am not sure why this is and have been fighting this issue for about a week; any help is much appreciated.
#define ADC_CHANNELS 3
uint16_t adcResultsDMA[ADC_CHANNELS];
int adcConversionComplete = 0; char message[32];if (HAL_ADC_Start_DMA(&hadc1, (uint16_t*)adcResultsDMA, ADC_CHANNELS) != HAL_OK) {
Error_Handler();
}
/* Infinite loop */
while (1) {
if (adcConversionComplete == 1) {
sprintf(message, "%d -- %d -- %d\r\n", adcResultsDMA[0], adcResultsDMA[1],
adcResultsDMA[2]);
HAL_UART_Transmit_IT(&huart3, message, sizeof(message)); HAL_Delay(1);
adcConversionComplete = 0;
}void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) {
adcConversionComplete = 1;
}
