2025-07-13 8:21 PM - last edited on 2025-07-14 9:23 AM by Andrew Neil
Hello everyone.
I am using st32f407 chip to drive ad7606c ADC chip, and I want to output real time graph from PC to matlab via usb.
ad7606c outputs busy signal at the end of conversion, and GPIO callback function is executed like below according to busy signal.
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
if(GPIO_Pin == BUSY_Pin && dma_busy == 0) {
Start_ADC_DMA_Receive();
}
}
Then the ‘Start_ADC_DMA_Receive()’ function is executed, which is shown below.
// Start receiving DMA (call only once, repeat in subsequent callbacks)
void Start_ADC_DMA_Receive(void) {
dma_busy = 1;
//HAL_GPIO_TogglePin(GPIOD, GPIO_PIN_3); // Toggle LEDs for status checking
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_RESET); // CS Low
However, if the DMA reception completion callback function is not executed afterward, the PA3(CS) pin output does not go high. The code is shown below.
// DMA Receive Complete Callback
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef *hspi) {
if (hspi->Instance == SPI1) {
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_3, GPIO_PIN_SET); // CS High
Why is the DMA callback function not executing?
I'll provide the full code as an attachment.
Edited to apply source code formatting - please see How to insert source code for future reference.
2025-07-14 7:52 AM
Hello @ildong
You only initialize the RX DMA handle, but you use HAL_SPI_TransmitReceive_DMA() which requires both TX and RX DMA handles to be properly initialized and linked.
You need to initialize and link the TX DMA handle (hdma_spi1_tx) as well, because HAL_SPI_TransmitReceive_DMA() uses both TX and RX DMA streams.
Please refer to the example below: