2023-07-25 07:37 PM - edited 2023-07-25 07:40 PM
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;
}
Solved! Go to Solution.
2023-07-27 05:39 PM
The issue was too many interrupts being triggered. Found a happy medium between buffer size an adc conversions and it is now working well.
2023-07-25 08:57 PM
AN4891 study. If I'm not mistaken, DMA has no access to AXI memory in the domain D1, ldscript.ld has to be configured to work with D2 & D3
@brief Linker script for STM32H743ZITx Device from STM32H7 series
* 2048Kbytes FLASH
* 128Kbytes DTCMRAM
* 64Kbytes ITCMRAM
* 512Kbytes RAM_D1
* 288Kbytes RAM_D2
* 64Kbytes RAM_D3
*
2023-07-26 09:17 AM
I am sorry, but I am not sure that I understand your reply; could you elaborate?
2023-07-26 09:43 AM
32 Bytes is a cache line...
quick test: switch off D-cache (or dont switch on in Cube) - see, if it working better then. :)
2023-07-26 10:21 AM
O'k.
"AN4891 study. If I'm not mistaken, DMA has no access to AXI memory in the domain D1, ldscript.ld"
AN4891 is application note, locate it on st.com web site or use google.com as search engine. Read.
ldscript.ld is a config file, installed somewhere within H7 package on your computer, find it and post here.
Also it was disscused a few times on this board, search pattern "DMA stm32H74x", sure it worth to read
2023-07-26 03:32 PM
D-cache has been disabled the whole time, still having the same issue
2023-07-26 03:35 PM
Just to update my further progress, disabling continuous conversion mode allows the code to run fine. This obviously only takes one sample, however, which does not complete my goal.
I will read through the AN4891. Are there any sections I should focus on @MasterT?
2023-07-27 05:39 PM
The issue was too many interrupts being triggered. Found a happy medium between buffer size an adc conversions and it is now working well.