cancel
Showing results for 
Search instead for 
Did you mean: 

timer interrupt

arunl4g
Associate II
Posted on December 02, 2015 at 14:05

hi

i have configurd to get an interrupt nce the timer update . But it did not work, can anyone knows whats the problem.

I am using stm32f429 discovery board...

 void timer_init()

 {

/**** clock for the timer *****/

RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, ENABLE);

// RCC->AHB2RSTR  |= timer2_RCC_Enable;

/*** timebase init and nested vector init *****/

TIM_TimeBaseInitTypeDef TIM_TimeBaseStruct;

/**** timer has the delay of 45MHz *****/

TIM_TimeBaseStruct.TIM_ClockDivision = 0;

TIM_TimeBaseStruct.TIM_CounterMode = TIM_CounterMode_Up ;

TIM_TimeBaseStruct.TIM_Period =  1000000-1; // 1Mhz to 1hz  which equals to  1s

TIM_TimeBaseStruct.TIM_Prescaler = 45-1;  //45 Mhz to 1 Mhz which equals to 1us

TIM_TimeBaseStruct.TIM_RepetitionCounter = 0 ;

TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStruct);

/**** Enable the timer ****/

/* start timer */

TIM_Cmd(TIM2, ENABLE);

/**** interrupt ****/

NVIC_InitTypeDef NVIC_IntStruct;

NVIC_IntStruct.NVIC_IRQChannel = TIM2_IRQn;

NVIC_IntStruct.NVIC_IRQChannelCmd = ENABLE;

NVIC_IntStruct.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_IntStruct.NVIC_IRQChannelSubPriority = 1 ;

NVIC_Init(&NVIC_IntStruct);

/*** interrupt on nvic ******/

TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);

 }

5 REPLIES 5
Posted on December 02, 2015 at 17:24

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); // Enable the clock, not hold the peripheral in reset?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on December 04, 2015 at 12:31

ok clive, i just wanna know whats mean holding the pheripheralin reset?... does it mean, stop giving clocks to pheriperal?

arunl4g
Associate II
Posted on December 04, 2015 at 14:07

clive, 

could you give me what the  

RCC_APB1PeriphResetCmd do?

and what you mean by 

not hold the peripheral in reset?

i am newbie and learn on my own.
Posted on December 04, 2015 at 14:23

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); //  Start the engine

RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, ENABLE); // Standing of the brakes

RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, DISABLE); // Remove foot from brake

Nothing is going to happen in the timer if you keep it in the reset state, and being synchronous logic, you need to have it's clock enabled.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunl4g
Associate II
Posted on December 04, 2015 at 14:31

thank you clive.

what happens when i give RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

and

after that RCC_APB1PeriphResetCmd(RCC_APB1Periph_TIM2, DISABLE); ?

any power saving ?.

if possible please tell me when do i need to use pheripheral  reset command ?