<?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>Timer 0 Interrupt</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/17665/timer-0-interrupt</link><description> Hi 
 
I am trying to use a Timer 0 as a 16-bit Timer to generate an Interrupt every 10 ms. In this example (downloaded from keil), the Interrupt is generated every 65536 clocks 
 
My question is how would i modify the example so that the interrupt is</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: Timer 0 Interrupt</title><link>https://community.arm.com/thread/72554?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2004 19:15:19 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:739a9337-1c5c-4be2-ac65-3d5efa2add71</guid><dc:creator>Mark H</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;
&lt;br /&gt;
Try this:-&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;
#define	XTAL			22.1184e6		/* system clock frequency */
#define	CLOCK_TICK_PERIOD	20e-3		/* time period required (= 20ms.) */
#define	CLOCK_TICK_RELOAD	(unsigned int)(-CLOCK_TICK_PERIOD * XTAL / 12)	/* Timer 0 16 bit relaod value for 20ms. clock tick */

TH0 = CLOCK_TICK_RELOAD / 0x100;   /* For my example a 20ms. Timer */
TL0 = CLOCK_TICK_RELOAD &amp;amp; 0xFF;
&lt;/pre&gt;
&lt;br /&gt;
You just need change the #defines to reflect your requirements and set up the timer to be 16 bit and reload when it overflows (and generates an IRQ?)&lt;br /&gt;
Mark.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer 0 Interrupt</title><link>https://community.arm.com/thread/42375?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2004 15:02:40 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:40d03afc-ad14-43cc-ad22-9d1f4d6e5323</guid><dc:creator>David Lively</dc:creator><description>&lt;p&gt;&lt;i&gt;&lt;br /&gt;
My question is how would i modify the example so that the interrupt is generated not according to the clock cycles, but rather by how much time passed away?&lt;br /&gt;
&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
It sounds like you want to reconfigure the chip so that that you get an interrupt every X milliseconds, instead of every X clock cyles. If so, you should know that it doesn&amp;#39;t work that way.&lt;br /&gt;
&lt;br /&gt;
Calculate the desired time interval in terms of clock cycles. Interrupts are based on clock cycles, not objective time. You&amp;#39;ll need to take into account the number of clock cycles per second (based on your device and your oscillator frequency) and write a function that translates milliseconds into cycles, and places that value in the timer reload register.
&lt;br /&gt;
Also, the resolution of this timing method is a limiteddue to your chip&amp;#39;s internal clock multiplier/divisor/whatever, interrupt latency and your oscillator frequency.  Good luck!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Timer 0 Interrupt</title><link>https://community.arm.com/thread/42374?ContentTypeID=1</link><pubDate>Thu, 17 Jun 2004 14:04:38 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:25791840-2ad5-46bd-b35f-5b66801b4e94</guid><dc:creator>erik  malund</dc:creator><description>&lt;p&gt;expand this&lt;br /&gt;
&lt;pre&gt;void timer0_ISR (void) interrupt 1
{
TR0 = FALSE
TH0 = nnn
TL0 = mmm
TR0 = TRUE
overflow_count++; /* Increment the overflow
}
&lt;/pre&gt;
&lt;br /&gt;
Then it will count up from nnmm and you can get whatever interval you want.&lt;br /&gt;
&lt;br /&gt;
Erik&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>