HI,
I am using STR91x
I wish to provide delay using timer in my program.
while studying the timer i came to know in str91 there are different modes like OC,IC.
(I am not using PWM mode).What does they meant for,which one is suitable for giving a delay.
Guys,
I got the way,
TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB; TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNEL_1; // OUTPUT COMPARE CHANNEL 1 Mode TIM_InitStructure.TIM_Prescaler = 0xFF; TIM_InitStructure.TIM_OC1_Modes = TIM_TIMING; //Timing mode TIM_InitStructure.TIM_Pulse_Length_1 = 0xFFEE; // .67s period TIM_Init(TIM0, &TIM_InitStructure);
the above calculation IRQ handler is written in the following way
void TIM0_IRQHandler(void) { GPIO_Write(GPIO3,0x00); TIM_CounterCmd(TIM0, TIM_CLEAR); // Clear TIM0 flag OC1 TIM_ClearFlag(TIM0,TIM_FLAG_OC1); }
using this i m getting my LED glows every .67sec.
now if i wish to toggle the led for example say 3 minutes so what i m supposed to do.
i can get the counter value using the standard function specified.
Tell me if this kind of coding is a gud practise