cancel
Showing results for 
Search instead for 
Did you mean: 

Hardfault after start Timer in DMA mode

VLajo.1
Associate II

hey!

I'm using timer 1 in OC mode with toggling the output. I also want to change the timer overflow value with the values predefined in the buffer.

I define buffer as:

uint16_t data[5] = { 50, 50, 100, 50, 50};

Then in main I call:

HAL_TIM_OC_Start_DMA(&htim1, TIM_CHANNEL_1, (uint32_t *) data, 5);

Hardfault strikes inside HAL_TIM_OC_Start_DMA:

htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;

My question is how avoid this.

Attached Cube initialization of TIM and DMA.

Alternatively, maybe there is different approach. My goal is to get signal without interrupts that looks like this with exact frequency:

0 1 0 1 0 1 1 0 1 0 1

Thanks

10 REPLIES 10

Using HAL is always a hit-or-miss chance game.