2020-10-21 01:02 PM
I am expecting there must be a similar callback function like HAL_UART_TxCpltCallback, HAL_UART_TxHalfCpltCallback in case of using UARTs when using DMA-burst for generating arbitrary waveforms with PWM in order to be able to update the memory buffer used for DMA?
I only can find callbacks which get called with every PWM pulse.
2020-10-21 01:59 PM
You can register your own callback functions by using HAL_DMA_RegisterCallback like
HAL_DMA_RegisterCallback( htim3.hdma[TIM_DMA_ID_CC3], HAL_DMA_XFER_HALFCPLT_CB_ID, XferHalfCpltCallback );
where void XferHalfCpltCallback(DMA_HandleTypeDef * _hdma) is the callback function which you implement.
2020-10-21 02:20 PM
Thank you. I have briefly tried this already, but I'll try again. I was asuming the TIM_PWM code is consuming the DMA callbacks.
2020-10-21 02:46 PM
2020-10-22 11:37 AM
You're right. Started your code and set a breakpoint on the native IRQ Handler DMA1_Channel7_IRQHandler which is hit. Stepping further I ended up at the __weak default HAL_TIM_PWM_PulseFinishedHalfCpltCallback. Defining your own HAL_TIM_PWM_PulseFinishedHalfCpltCallback should work.
2020-10-22 12:40 PM
yep, that what was my conclusion, too. But it's called with every pulse and not when DMA transfer is complete or half complete. Or maybe I misinterpreted that.
2023-04-14 03:08 AM
void HAL_TIM_PeriodElapsedHalfCpltCallback(TIM_HandleTypeDef *htim)
works great and is called at the end of the DMA Transfers.