cancel
Showing results for 
Search instead for 
Did you mean: 

HRTIM settings initialized via HAL drivers - problem with interrupts

ELowe
Associate III

Hi all!

I am trying to catch an interrupt with high resolution timer HRSTIM, timer D, on SMT32 board NUCLEO H743ZI.

The startup code was generated via CubeMX. Interrupt setup is presumably correct.

I can see in the generated code that HRTIM initialization function MX_HRTIM_Init(void) is called, which has following line of code:

 pTimerCfg.InterruptRequests = HRTIM_TIM_IT_REP|HRTIM_TIM_IT_UPD |HRTIM_TIM_IT_RST|HRTIM_TIM_IT_DLYPRT;

...so interrupt settings seems OK.

NIVIC is also configured for TimerD's global interrupt, and finally...... TimerD's counter was started.....and everything should work, but it doesn't ...... so here starts debugging phase which involves digging up through HAL code.....

So my MX_HRTIM_Init(void) ends with following lines of code:

...

 pTimerCfg.ResetTrigger = HRTIM_TIMRESETTRIGGER_NONE;

 pTimerCfg.ResetUpdate = HRTIM_TIMUPDATEONRESET_DISABLED;

 if (HAL_HRTIM_WaveformTimerConfig(&hhrtim, HRTIM_TIMERINDEX_TIMER_D, &pTimerCfg) != HAL_OK)

 {

   Error_Handler();

 }

....so I looked inside function HAL_HRTIM_WaveformTimerConfig........and at the end of this function was following line of code:

 /* Update timer parameters */

 hhrtim->TimerParam[TimerIdx].InterruptRequests = pTimerCfg->InterruptRequests;

 hhrtim->TimerParam[TimerIdx].DMARequests = pTimerCfg->DMARequests;

 hhrtim->TimerParam[TimerIdx].DMASrcAddress = pTimerCfg->DMASrcAddress;

 hhrtim->TimerParam[TimerIdx].DMADstAddress = pTimerCfg->DMADstAddress;

 hhrtim->TimerParam[TimerIdx].DMASize = pTimerCfg->DMASize;

 

 /* Force a software update */

 HRTIM_ForceRegistersUpdate(hhrtim, TimerIdx);

   hhrtim->State = HAL_HRTIM_STATE_READY;

 

 /* Process Unlocked */

 __HAL_UNLOCK(hhrtim); 

 

 return HAL_OK;

.....well now, no wonder it doesn't work, interrupt register TIMDDIER is not set! Instead, we can see in the following line:

hhrtim->TimerParam[TimerIdx].InterruptRequests = pTimerCfg->InterruptRequests;

....that configuration defined in CubeMX, which is stored in pTimerCfg->InterruptRequests ends up in array TimerParam, which is a part of hhrtim struct, and it does NOT end in TimerD's register TIMDDIER, and that's why there are not interrupts.

Now comes the question: What am I missing? How are interrupt settings supposed to get from:

hhrtim->TimerParam[TimerIdx].InterruptRequests

to:

hhrtim->Instance->sTimerxRegs[HRTIM_TIMERINDEX_TIMER_D].TIMxDIER

Of course, I can simply ignore HAL and do that by myself, but I am curious to find out what was thinking the person who wrote HAL drivers.....

Any suggestions?

0 REPLIES 0