2017-08-03 10:00 AM
hey all
i configed timer for 1us timer interrupt but how can i be sure my timer interrupt is 1us ?
my microcontroller is stm32f103c8t6 her RCC configed with pll on 72Mhz
external crystal 8Mhz
my timer function
void TIMER_Config(TIM_TypeDef* timer, uint16_t Period, uint16_t Prescaler, uint16_t ClockDivision, uint16_t CounterMode, FunctionalState status){
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructure.TIM_Period = Period;
TIM_TimeBaseStructure.TIM_Prescaler = Prescaler; TIM_TimeBaseStructure.TIM_ClockDivision = ClockDivision; TIM_TimeBaseStructure.TIM_CounterMode = CounterMode; TIM_TimeBaseInit(timer, &TIM_TimeBaseStructure); TIM_ARRPreloadConfig(timer, status);//TIM4 Config for 1ms interruptTIM_ClearITPendingBit(timer, TIM_IT_Update);
TIM_ITConfig(timer, TIM_IT_Update, status); TIM_SetCounter(timer, 0); TIM_Cmd(timer, status);}my nvic function
void NVIC_Config(uint8_t IRQChannel, uint8_t PreemptionPriority, uint8_t SubPriority , FunctionalState status){
NVIC_InitTypeDef NVIC_InitStructure;NVIC_InitStructure.NVIC_IRQChannel = IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = PreemptionPriority; NVIC_InitStructure.NVIC_IRQChannelSubPriority = SubPriority; NVIC_InitStructure.NVIC_IRQChannelCmd = status; /*TIM4 Interrupt configuration*/NVIC_Init(&NVIC_InitStructure);
}and my timer configuration is
// TIM3 Configuration
NVIC_Config(TIM3_IRQn, 0, 1 , ENABLE); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM3,ENABLE); TIMER_Config(TIM3,360, 1, 0, TIM_CounterMode_Up,ENABLE);please help
thanks
amin
2017-08-04 12:59 AM
A quick and dirty way:
If you have an LED driven by GPIO, create a global 32bit variable which will be incremented within the 1us interrupt and overflow at 500000
pseudo code:
==> 1us interrupt ISR, add:
if((count++)%1000000)==0 ToggleLED();
Then check the LED blinking period is 1 second.