2025-06-26 3:33 AM
I cant get faster SPI performance, in every SPI DMA request mcu receiving 164 bytes of data, the maximum request rate what I got is about 1KHz, total number of bytes is only ~ 164 * 1000 = 164KB, I need to reach 8KHz rate, MCU and other clocks is set to almost maximum values, on STM32H7 MCU with many other tasks I reached without any problems 12KHz rate, with N6 I cant get event near of required transfer speed in any configurations, If I rising request rate I getting SPI busy error, where can be the problem ? What peripherals or other settings is responsible for SPI transfer and interfere there ? I can attach .IOC file or more info.
In my setup SPI requests is controlled by HAL_TIM_PeriodElapsedCallback(), sometimes I need to stop requests in case when synchronization is lost, timer fires function for next SPI DMA transfer and in case of error (in my case I getting SPI busy error) the timer for request is stopped, timer fires simple function:
void nextPacket(){
if (HAL_SPI_Receive_DMA(&hspi5, buff, 164) != HAL_OK) {
HAL_TIM_Base_Stop_IT(&htim16);
printf("Spi E\n");
}
}
There is no difference if I choosing GPDMA1 or HPDMA1, the transfer rate does not reaching more, same is for SPI frequency.
DMA settings:
SPI settings:
2025-06-26 6:23 AM
Show your code and show why you think the max request rate is 1 kHz. Almost certainly a code bug here. Consider not calling printf in code you want to be fast.
2025-06-26 8:55 AM - edited 2025-06-26 9:18 AM
Printf fires just in case when there is spi error, for tests in SPI callback I commented out everything except LED toggle, with oscilloscope I checked led toggle freq to confirm, I miscalculated before, real frequency is 2x because there is used toggle, and I checked more what I can get, I reached ~4kHz, in my code there just simple functions for test:
void HAL_SPI_RxCpltCallback(SPI_HandleTypeDef * hspi){
if (hspi->Instance == SPI5) HAL_GPIO_TogglePin(GPIOP, GPIO_PIN_7);
}