cancel
Showing results for 
Search instead for 
Did you mean: 

TIM1 interrupt STM32F0

mosine
Associate II
Posted on September 15, 2014 at 13:56

Hi,

I need to know if it's possible configure TIM1 as timer base (I need interrupt every 5 msec). 

Thanks
5 REPLIES 5
Posted on September 15, 2014 at 16:53

I need to know if it's possible configure TIM1 as timer base (I need interrupt every 5 msec). 

Why wouldn't it be? Factor Prescaler and Period to get 200 Hz from whatever TIMCLK you're using.

24000000 / 200 = 120000

2  * 60000 = 120000

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
mosine
Associate II
Posted on September 17, 2014 at 12:24

Hi Clive1,

thanks for reply. I resolved by another way 🙂

I need to know the interrupt of TIM1 handler (for TIM3 is: TIM3_IRQHandler).

Posted on September 17, 2014 at 19:16

To understand available interrupts you could review startup_stm32f0xx.s

                DCD     TIM1_BRK_UP_TRG_COM_IRQHandler ; TIM1 Break, Update, Trigger and Commutation

                DCD     TIM1_CC_IRQHandler             ; TIM1 Capture Compare

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
mosine
Associate II
Posted on September 18, 2014 at 08:25

Hi clive,

thanks for reply. This is my code; but doesn't work:

void TIM1Conf(void){
NVIC_InitTypeDef NVIC_InitStructure;
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_TIM1 , ENABLE);
TIM_TimeBaseStructure.TIM_Prescaler = (uint16_t) (((SystemCoreClock / 1000000)/2) - 1);
TIM_TimeBaseStructure.TIM_Period = 10000 - 1; 
TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; 
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
TIM_TimeBaseStructure.TIM_RepetitionCounter = 0;
TIM_TimeBaseInit(TIM1, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE);
TIM_Cmd(TIM1, ENABLE); 
/* Interrupt Timer1 */ 
NVIC_ClearPendingIRQ(TIM1_BRK_UP_TRG_COM_IRQn);
NVIC_InitStructure.NVIC_IRQChannel = TIM1_BRK_UP_TRG_COM_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
void TIM1_BRK_UP_TRG_COM_IRQHandler (void){
if(TIM_GetITStatus(TIM1, TIM_IT_Update) != RESET)
{
 //

my operations
TIM_ClearITPendingBit(TIM16, TIM_IT_Update);
}
}

John F.
Senior
Posted on September 18, 2014 at 09:15

TIM_ClearITPendingBit(TIM16, TIM_IT_Update);

TIM16 ?