cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 dma request synchronization settings

ali_dehbidi
Senior

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.

 

1 REPLY 1
Sarra.S
ST Employee

Hello @ali_dehbidi

Please check this thread 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.