cancel
Showing results for 
Search instead for 
Did you mean: 

Timer 1 Channel 4 -Compare interrupt problem

rob239955_stm1_stmicro
Associate II
Posted on January 30, 2018 at 16:00

Trouble getting capture compare ( no output ) interrupt to function correctly.

First.. I'm using HAL, with the free Keil MDK. Maybe this is the problem, so first question:

Is there any simple Keil examples that like Blinky that also don't force an RTOS on me?

Trying to generate a basic Keil project seemed to invole HAL when I requested  startup code to be generated.

Back to the main problem,  using Timer 1 Channel 4. I want no output, just the Compare to generate an interrupt.

The timer will re restarted by an external interrupt.

The only thing that happens is the CC interrupt seems to fire at the counter end ( if left to continue without resetting )4or it fired when the external int restarts the counter.

The CC interrupt seems to fire correctly only once ( count matches compare)  after a program reset. from then on the compare value doesn't seem to do anything ( yet the CC interrupt triggers - at the count end)

2 REPLIES 2
Posted on January 30, 2018 at 17:12

On what device? STM32 refines the list to a few hundred parts from different families.

Make sure you have the IRQ Handler for the interrupt calling the HAL layer

TIM1_CC_IRQHandler ?? Check the vector table for the device in question

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on January 30, 2018 at 17:38

Its the 32F030F4P, the small 20pin chip.

I'm not sure what you mean, HAL creates its own general TIM IRQ Handler - and that get's called, which then calls my own callback.

 void HAL_TIM_OC_DelayElapsedCallback(TIM_HandleTypeDef *htim) //Output Compare callback in non blocking mode.

That's the function that gets called regularly if the interrupt is enabled, but not at all if the interrupt is disabled.

It's just that the count value at the point of being called bears no relation to the Compare register when viewed in the debugger.

A pin is toggled within the interrupt handler .. that happens with regularity, but it happens with no regard to the compare value, rather it happens when the counter overflows or is reset.

It looks like its actioning an update event interrupt - rather than a compare.  But it's most definitely only the CC4IE that's enabled.

So far spent days trying to get a simple compare interrrupt to function!!!