STM32f407 MCU two interrupts at some time
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-24 5:13 PM
Posted on July 25, 2015 at 02:13
I used TIMER 2. It's interrupt time is 1us.
I made one long pulse and short pulse using GPIO output pin and TIMER 2.but sometimes, interrupts occurred two times.First figure is the result I want to get.Second figure is the result I can get now.At second figure the red circle is an error I think.It's shivering in trigger mode.Here is my codevoid TIM2_IRQHandler(void){ //TIM_ClearITPendingBit(TIM2, TIM_IT_Update); assert_param(IS_TIM_ALL_PERIPH(TIM2)); TIM2->SR = (uint16_t)~0x0001; //////Enable pin wait.(1us) for(a=0;a<33;a++){ GPIOB->BSRRL = GPIO_Pin_0; } //wait(300ns) for(a=0;a<10;a++){ GPIOB->BSRRH = GPIO_Pin_0;} //one more short pulse(20ns) GPIOB->BSRRL = GPIO_Pin_0; GPIOB->BSRRH = GPIO_Pin_0;}
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-24 6:13 PM
Posted on July 25, 2015 at 03:13
Suggest you qualify the source of the interrupt, and consider if the problem is elsewhere in your code.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Up vote any posts that you find helpful, it shows what's working..
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-07-24 9:07 PM
Posted on July 25, 2015 at 06:07
This is my Timer setting
void TIMER2_Init(void){ TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseStructure.TIM_Period = 9; TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1; TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseStructure.TIM_RepetitionCounter = 0x0000; TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure); TIM_PrescalerConfig(TIM2, 83, TIM_PSCReloadMode_Immediate); TIM_ClearFlag(TIM2, TIM_FLAG_Update); TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE); TIM_Cmd(TIM2, ENABLE);}