Skip to main content
Vthe
Associate
August 5, 2019
Solved

Cannot use SPI and PWM DMA together on STM32F103VET6

  • August 5, 2019
  • 2 replies
  • 1038 views

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?

This topic has been closed for replies.
Best answer by waclawek.jan

>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

2 replies

waclawek.jan
waclawek.janBest answer
Super User
August 5, 2019

>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
VtheAuthor
Associate
August 6, 2019

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