From b7940f19e24a5e51e117d012c756be528fa08b4b Mon Sep 17 00:00:00 2001 From: blckmn Date: Mon, 9 Jan 2017 22:08:14 +1100 Subject: [PATCH] Ensure timer dma source is disabled before resetting during motor write. --- src/main/drivers/pwm_output_stm32f4xx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/drivers/pwm_output_stm32f4xx.c b/src/main/drivers/pwm_output_stm32f4xx.c index 09b0b001b..6515fdce0 100644 --- a/src/main/drivers/pwm_output_stm32f4xx.c +++ b/src/main/drivers/pwm_output_stm32f4xx.c @@ -82,9 +82,11 @@ void pwmWriteDigital(uint8_t index, uint16_t value) packet <<= 1; } - DMA_ClearITPendingBit(motor->timerHardware->dmaStream, motor->dmaFlag); - DMA_SetCurrDataCounter(motor->timerHardware->dmaStream, MOTOR_DMA_BUFFER_SIZE); - DMA_Cmd(motor->timerHardware->dmaStream, ENABLE); + DMA_Stream_TypeDef *stream = motor->timerHardware->dmaStream; + TIM_DMACmd(motor->timerHardware->tim, motor->timerDmaSource, DISABLE); + DMA_SetCurrDataCounter(stream, MOTOR_DMA_BUFFER_SIZE); + DMA_ClearITPendingBit(stream, motor->dmaFlag); + DMA_Cmd(stream, ENABLE); } void pwmCompleteDigitalMotorUpdate(uint8_t motorCount)