2024-08-11 10:11 PM - edited 2024-08-18 04:32 AM
I am transfering data array from an array to PWM register of TIM1.
int16_t sin_table[20]= { 0, 39, 77, 113, 147, 177, 202, 223, 238,247, 250, 247, 238, 223, 202, 177, 147, 113, 77, 39};
HAL_TIM_PWM_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *)sin_table, 20);
And i am trying to blink in complete transfer callback fuction as follows .
I am getting PWM signal as expected . but trigger the TransferCompleteCallback).
by using break poiint the DMA Inerupt Handler triggers but not trigger the callback i said .
whats the wrong am with please help me .
i am attaching the full code here
aNY BODY HELP ME
2024-08-18 04:33 AM - edited 2024-08-19 09:48 AM
2024-08-18 04:54 AM
Seems you missunderstan HAL callbacks ... read examples in folder repository firmware for your MCU...
You mark all MCUs, this isnt very helpfull. For example F4 from stm32f4xx_hal_tim.c func HAL_TIM_PWM_Start_DMA
switch (Channel)
{
case TIM_CHANNEL_1:
{
/* Set the DMA compare callbacks */
htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
2024-08-19 02:02 AM - edited 2024-08-19 02:03 AM
Hi Thanks , I didnt find any examples related DMA transfer complete function trigger based projects .
Hi may i need to register the following function to trigger the calla back function
HAL_DMA_RegisterCallback(&hdma, HAL_DMA_XFER_CPLT_CB_ID, My_DMA_TransferCompleteCallback);
Or any other way to do this , is there tutorials or mannual for it ?
2024-08-19 07:32 AM
Simply HAL prepare weak for you and yu cant choice any func, but need overide.
/**
* @brief PWM Pulse finished callback in non-blocking mode
* @PAram htim TIM handle
* @retval None
*/
__weak void HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(htim);
/* NOTE : This function should not be modified, when the callback is needed,
the HAL_TIM_PWM_PulseFinishedCallback could be implemented in the user file
*/
}
then rename in your code void TransferCompleteCallback to HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim)
2024-08-19 08:34 AM
Hi
HAL_TIM_PWM_PulseFinishedCallback(TIM_HandleTypeDef *htim) is used for one complete cycle isnt it ?
or one ARR value .
I require ne complete array finished that array has a lot of array elements for example 360 elements
HAL_TIM_PWM_PulseFinishedCallback will triger 360 it require extra logic .
can i directly implement DMA complete transfer call back ?