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.
Hi I aam sending code for timer problem is that code goes inside handler for a long time (till then LED is off) please suggest the right code
void main(void) { #ifdef DEBUG debug(); #endif SCU_APBPeriphClockConfig(__TIM01, ENABLE); /* Enable the clock for TIM0 and TIM1 */ TIM_DeInit(TIM0); /* TIM0 Deinitialization */ SCU_APBPeriphClockConfig(__TIM23, ENABLE); /* Enable the clock for TIM2 and TIM3 */ TIM_DeInit(TIM2); /* TIM2 Deinitialization */ SCU_APBPeriphClockConfig(__GPIO9, ENABLE); /* GPIO Structure Initialization */ GPIO_StructInit(&GPIO_InitStructure); SCU_AHBPeriphClockConfig(__VIC,ENABLE); SCU_AHBPeriphReset(__VIC,DISABLE); VIC_DeInit(); VIC_Config(TIM2_ITLine, VIC_IRQ, 0); VIC_ITCmd(TIM2_ITLine, ENABLE); /*GPIO9 for LED*/ GPIO_DeInit(GPIO9); GPIO_InitStructure.GPIO_Direction = GPIO_PinOutput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0|GPIO_Pin_1 ; GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull ; GPIO_Init (GPIO9, &GPIO_InitStructure); GPIO_WriteBit(GPIO9, GPIO_Pin_0, Bit_RESET); GPIO_WriteBit(GPIO9, GPIO_Pin_1, Bit_RESET); /*TIM2 Structure Initialization*/ TIM_StructInit(&TIM_InitStructure); TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNEL_1; TIM_InitStructure.TIM_OC1_Modes = TIM_TIMING; TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB; TIM_InitStructure.TIM_Prescaler = 0xFFFF; TIM_InitStructure.TIM_Pulse_Length_1 = 0xFF; TIM_Init (TIM2, &TIM_InitStructure); //TIM_ITConfig(TIM2, TIM_IT_TO, ENABLE); TIM_ITConfig(TIM2, TIM_IT_TO, ENABLE); TIM_ITConfig(TIM2, TIM_IT_OC1, ENABLE); //Delay(0xFCD); GPIO_WriteBit(GPIO9, GPIO_Pin_1, Bit_SET); //GPIO_WriteBit(GPIO9, GPIO_Pin_1, Bit_RESET); TIM_CounterCmd(TIM2, TIM_START); } void TIM2_IRQHandler(void) { TIM_ClearFlag(TIM2, TIM_FLAG_TO); GPIO_WriteBit(GPIO9, GPIO_Pin_1, Bit_RESET); VIC0->VAR = 0; /*Acknowledge Interrupt */ // VIC1->VAR = 0; }
thanks dude I got the solution nice reply