LL DMA Burst to a Timer not working on STM32H7
- November 23, 2021
- 3 replies
- 3113 views
Hello,
I am trying to use the DMA in burst mode to send data to a timer, to configure two PWM channels at every update event, but the DMA doesn't seem to write any data, however it doesn't trigger an error and triggers the transfer complete flag .
I am trying it on a Nucleo-H723ZG, Tim8 CH3 on PC8 and CH4 on PC9. I have also a debug Pin on PC10
I don't believe I have the usual memory problem with DCM: my data is at the address 0x24000020.
I believe I configured everything correctly:
#define K_LenBurst 16
uint16_t DataBurst[K_LenBurst];
void BurstInit(void) {
LL_DMA_SetMemoryAddress(DMA1, LL_DMA_STREAM_0,(uint32_t)DataBurst);
LL_DMA_SetPeriphAddress(DMA1, LL_DMA_STREAM_0,(uint32_t)&TIM8->DMAR);
LL_DMA_SetDataLength(DMA1, LL_DMA_STREAM_0,K_LenBurst);
LL_TIM_ConfigDMABurst(TIM8, LL_TIM_DMABURST_BASEADDR_CCR3, LL_TIM_DMABURST_LENGTH_2TRANSFERS);
LL_TIM_EnableDMAReq_UPDATE(TIM8);
LL_TIM_SetAutoReload(TIM8, 150);
LL_TIM_EnableCounter(TIM8);
LL_TIM_EnableAllOutputs(TIM8);
LL_TIM_CC_EnableChannel(TIM8, LL_TIM_CHANNEL_CH3 | LL_TIM_CHANNEL_CH4);
LL_DMA_EnableIT_TC(DMA1,LL_DMA_STREAM_0);
}Then I am runing this at 10Hz:
void Burst(void) {
int i,dataPtr;
dataPtr = 0;
LL_DMA_DisableStream(DMA1, LL_DMA_STREAM_0);
LL_DMA_ClearFlag_TC0(DMA1); //Just in case...
LL_GPIO_ResetOutputPin(Dbg_GPIO_Port, Dbg_Pin);
for (i=1; i<=16;i++) { //Filling random data
DataBurst[dataPtr++] = i<<2;
}
LL_DMA_SetDataLength(DMA1, LL_DMA_STREAM_0,K_LenBurst);
LL_DMA_EnableStream(DMA1, LL_DMA_STREAM_0);
}which trigers the interrupt at 10Hz:
void DMA1_Stream0_IRQHandler(void)
{
/* USER CODE BEGIN DMA1_Stream0_IRQn 0 */
/* USER CODE END DMA1_Stream0_IRQn 0 */
/* USER CODE BEGIN DMA1_Stream0_IRQn 1 */
LL_GPIO_SetOutputPin(Dbg_GPIO_Port, Dbg_Pin);
LL_DMA_ClearFlag_TC0(DMA1);
/* USER CODE END DMA1_Stream0_IRQn 1 */
}I can see the "Dbg" pin changing state at 10Hz, however the Timer8 CCR3 and CCR4 are always at 0.
In the debug window, if I change the CCR3 and CCR4 registers, then yes I can see a PWM output
The reference manual only shows these steps in the example "43.3.28 DMA burst mode".
I have attached my .ioc file, where I set-up the DMA in normal mode, no buffer and half word for both memory and peripheral.
Did anyone encounter this problem?
Thanks,
Marco
