2019-08-24 12:02 PM
I am trying to use the DMA of the STM32H750 to generate a specific PWM, but it does not output any waves.
HAL_TIM_PWM_Start(&htim2,TIM_CHANNEL_4);
__HAL_TIM_SET_COMPARE(&htim2,TIM_CHANNEL_4,50);
This is the code that usually generates pwm, it works, I can see pwm on the logic analyzer.
But if I use DMA, it will not output anything.
uint16_t buffer[10]={0};
buffer[0]=50;
buffer[1]=50;
buffer[2]=50;
HAL_TIM_PWM_Start_DMA(&htim2, TIM_CHANNEL_4, (uint32_t *)buffer, 10);
while(HAL_TIM_PWM_GetState(&htim2) != HAL_TIM_STATE_READY);
// HAL_TIM_PWM_GetState will get HAL_TIM_STATE_READY
It will get...
I passed the debugger and found that it fell into TIM_DMAError.
I observed that the value of ErrorCode for HDMA becomes 1, which is defined in stm32h7xx_hal_dma.h as
...
#define HAL_DMA_ERROR_TE (0x00000001U) /*!< Transfer error */
...
How can I solve this problem? I used the same code in STM32F042 and it works.
My cubemx configuration
Clock
TIM
DMA
Linker Strrings(default value)
2019-08-24 12:39 PM
Pretty sure TIM2 is 32-bit wide, should use array of 32-bit ints, DMA to TIM is likely at 32-bit already, but then your CCRx > ARR, ie 0x00320032
2019-08-24 02:11 PM
Thank you for your reply.
I changed the buffer array to uint32_t. Then set the DMA data width to 32-bit(Word).
Try again.DMA still doesn't work, ErrorCode is still 1.TIM seems to work fine, I can see that CNT is changing.
2019-08-25 11:53 PM
Isn't the memory where buffer variable lies, unaccessible to the DMA you've chosen?
JW