<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://dsignt.de/support-wiki/index.php?action=history&amp;feed=atom&amp;title=D2ts203_timer</id>
	<title>D2ts203 timer - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://dsignt.de/support-wiki/index.php?action=history&amp;feed=atom&amp;title=D2ts203_timer"/>
	<link rel="alternate" type="text/html" href="https://dsignt.de/support-wiki/index.php?title=D2ts203_timer&amp;action=history"/>
	<updated>2026-08-14T20:30:04Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://dsignt.de/support-wiki/index.php?title=D2ts203_timer&amp;diff=434&amp;oldid=prev</id>
		<title>Adolf at 23:29, 17 February 2011</title>
		<link rel="alternate" type="text/html" href="https://dsignt.de/support-wiki/index.php?title=D2ts203_timer&amp;diff=434&amp;oldid=prev"/>
		<updated>2011-02-17T23:29:52Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;=== Question ===&lt;br /&gt;
I want to trigger an event (data acquisition), using one of the I/O coming from the TS203, at as precise a time interval (maybe 100nS or 1mS) as possible&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Solution ===&lt;br /&gt;
Use the TS203 timer TMR0 to generate periodic pulses or clocks. The timer.c program from the support software can be used as a basis.&lt;br /&gt;
&lt;br /&gt;
The DSP timer output can be routed to one of the GPIO[3:0] pins on the BUS-1 and BUS-2 connectors. The DSP generates only a narrow pulse each time the timer expires. You can select either the direct TMR0E output (pulse), or the output of a toggle-flipflop driven by TMR0E (clock). The toggle-flipflop will divide the timer output by 2 and provide 50% duty cycle.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
 DM2_gpioMap (DM2_GPIO_TIMERPULSE, 3);  // TMR0E -&amp;gt; GPIO3&lt;br /&gt;
 DM2_gpioMap (DM2_GPIO_TIMERCLK, 3);    // TMR0E -&amp;gt; toggle-ff -&amp;gt; GPIO3&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The timer input clock is SYSCLK. To initialize and start the timer use:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
  DM2_timerStart (0, DM2_dspGetClock()/output_frequency_in_hz);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If the toggle-flipflop output is used:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
  DM2_timerStart (0, DM2_dspGetClock()/(2*output_frequency_in_hz));&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A timer interrupt is installed with&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c&amp;quot;&amp;gt;&lt;br /&gt;
  int temp;&lt;br /&gt;
&lt;br /&gt;
  interruptf(SIGTIMER0LP, timer_int); &lt;br /&gt;
  temp = __builtin_sysreg_read(__IMASKL);&lt;br /&gt;
  temp = temp | INT_TIMER0L;&lt;br /&gt;
  __builtin_sysreg_write(__IMASKL, temp);&lt;br /&gt;
  temp = __builtin_sysreg_read(__SQCTL);&lt;br /&gt;
  temp = temp | SQCTL_GIE;&lt;br /&gt;
  __builtin_sysreg_write(__SQCTL, temp);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The interrupt function will be called periodically, but with some jitter: the interrupt code execution is delayed until the current instruction has completed. If this instruction accesses external memory, or if a DRAM refresh cycle is in progress, the interrupt will be delayed. Therefore we do not recommend to toggle an output &amp;quot;manually&amp;quot; in the interrupt service function. For lowest jitter always use the timer output directly.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:D.Module2.TS203]]&lt;br /&gt;
[[Category:Timer]]&lt;/div&gt;</summary>
		<author><name>Adolf</name></author>
	</entry>
</feed>