Skip to main content
Visitor II
January 14, 2024
Question

stm32 dma request synchronization settings

  • January 14, 2024
  • 1 reply
  • 2852 views

Hi,
I have an external SPI 8 channel ADC which is connected to the STM32,one of timers would generate a 32KHz 50% pwm signal which is connected to the ADC convert pin, the ADC has a busy pin which is connected to the EXTI0 of the MCU.

The plan is to use the EXTI0 to trigger 8 16bit SPI reads from the ADC, so after gathering 640 samples I would get an interrupt, to process the incoming data, since Interrupting the CPU 32000 times  per second would not allow any other meaning full job to be done,

So I have done like this

Pin A0 configured as EXTI0

Screenshot 2024-01-14 165113.png

SPI DMA settings

Screenshot 2024-01-14 165135.png

SPI NVIC settings

Screenshot 2024-01-14 165144.png

my code is like this

 

uint8_t SPISend = 1;

void  HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi){
if (hspi->Instance == SPI2) {
SPISend = 1;
}
}

int main(void){
   uint8_t tx[5120]={0,0,1,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88};
   uint8_t rx[5120]={0};
   //init IO with CubMX
   while (1){
     if(SPISend == 1){
        HAL_SPI_TransmitReceive_DMA(&hspi2,tx,rx,5120);
     }
   }

}

This code works only when I enable the EXTI interrupt, which would ruin the hole prepose of eliminating the use of interrupts,

Screenshot 2024-01-14 165120.png

Is there any work around this so I would reduce the CPU overhead and interrupts, so the CPU could do other time critical tasks.

 

    This topic has been closed for replies.

    1 reply

    ST Employee
    January 15, 2024

    Hello @ali_dehbidi

    Please check this thread