We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
i would like to use the output compare 1 Interrupt. What do I have to add (or remove) to following code, so that it works?
TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNEL_1; TIM_InitStructure.TIM_OC1_Modes = TIM_TIMING; TIM_InitStructure.TIM_Clock_Source =TIM_CLK_EXTERNAL; TIM_InitStructure.TIM_Pulse_Length_1 = 25000; TIM_Init (TIM1, &TIM_InitStructure); TIM_CounterCmd(TIM1, TIM_START); VIC0->VAiR[5] = (unsigned int)TIM1_IRQ_Handler;
kind regards don
I'm trying to set up the timer so that it compares the freerunning counter with the compare register and when those registers match, then it should jump into the Interrupt Handler subroutine, or at least set the interrupt flag, for which I can poll.
Actually I do this, like discribed in the ref-manual, but obviously the interrupt Flag is never set!
To use the output compare function, select the following in the TIM_CR1 and TIM_CR2 registers:
1) Set the OCiE bit if an output is needed then the OCMPi pin is dedicated to the output compare i function. 2) Select the timer clock ECKEN and program the prescaler (CC[7:0]). 3) Select the OLVLi bit to applied to the OCMPi pins after the match occurs. (I don't need this) 4) Set the OCiIE bit to generate an interrupt if required.
I do this with following code:
TIM1->CR1 &= 0xFFBF; //OCMP1 = 0 TIM1->CR1 != 0x0001; //ECKEN = 1 TIM1->CR1 &= 0xFDFF; //OLVL1 = 0 TIM1->CR2 != 0x4000; //OC1IE = 1