<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Providing Delay Using Timer</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/13663/providing-delay-using-timer</link><description> 
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</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Providing Delay Using Timer</title><link>https://community.arm.com/thread/36850?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2012 23:38:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:fc5ec1ba-eb8b-4993-8e84-6d3048ae8067</guid><dc:creator>Saurabh Yadav</dc:creator><description>&lt;p&gt;&lt;p&gt;
Guys,&lt;/p&gt;

&lt;p&gt;
I got the way,&lt;/p&gt;

&lt;pre&gt;

 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, &amp;amp;TIM_InitStructure);

&lt;/pre&gt;

&lt;p&gt;
the above calculation&lt;br /&gt;
IRQ handler is written in the following way&lt;/p&gt;

&lt;pre&gt;

void TIM0_IRQHandler(void)
{
  GPIO_Write(GPIO3,0x00);
  TIM_CounterCmd(TIM0, TIM_CLEAR);
  // Clear TIM0 flag OC1
  TIM_ClearFlag(TIM0,TIM_FLAG_OC1);
}
&lt;/pre&gt;

&lt;p&gt;
using this i m getting my LED glows every .67sec.&lt;/p&gt;

&lt;p&gt;
now if i wish to toggle the led for example say 3 minutes so what
i m supposed to do.&lt;/p&gt;

&lt;p&gt;
i can get the counter value using the standard function
specified.&lt;/p&gt;

&lt;p&gt;
Tell me if this kind of coding is a gud practise&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>