cancel
Showing results for 
Search instead for 
Did you mean: 

Cannot use SPI and PWM DMA together on STM32F103VET6

Vthe
Associate II

I'm using CubeMX for code generation.

I configured my MCU (STM32F103VET6) for PWM generation on Timer 2 Channel 2 using DMA (DMA 1 channel 7), Memory to Peripherial; PWM data stored in array.

All works good, if I fill data array programmatically.

When I read data to array from SPI flash (I checked readed array in debugger, it contains right data), I cannot start PWM DMA.

For firmware versions before 1.8.0 (I've checked 1.6.1 and 1.7.0) call of HAL_SPI_Transmit() changes hdma->State to HAL_DMA_STATE_RESET (so HAL_TIM_PWM_Start_DMA() will not start at all). Firmware versions 1.8.0 keeps hdma->State value HAL_DMA_STATE_READY after HAL_SPI_Transmit(), but HAL_TIM_PWM_Start_DMA() falls into HardFault.

Unfortunately, cannot check SPI2 and SPI3, only SPI1 is available on board.

Is it normal behaviour for this MCU?

1 ACCEPTED SOLUTION

Accepted Solutions

>call of HAL_SPI_Transmit() changes hdma->State

Something is seriously wrong in your program, a polled Tx from SPI should not overwrite any variable in memory.

JW

View solution in original post

2 REPLIES 2

>call of HAL_SPI_Transmit() changes hdma->State

Something is seriously wrong in your program, a polled Tx from SPI should not overwrite any variable in memory.

JW

Vthe
Associate II

Thanks for your response. I've recreated project again, this error has gone.