<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Timer and UART confugration]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I want to send radnom values via UART every second. I've got this code:</p>
<p dir="auto">uart = UART(0,  baudrate=115200)</p>
<p dir="auto">def irq_handler(value):<br />
str1 = str(value) + &quot;\r\n&quot;<br />
uart.write(str1)<br />
value += 1</p>
<p dir="auto">tim = Timer(0, mode=Timer.PERIODIC)<br />
tim_a = tim.channel(Timer.A, freq=1000)<br />
tim_a.freq(5)</p>
<p dir="auto">it = 0</p>
<p dir="auto">tim_a.irq(trigger=Timer.TIMEOUT, handler=irq_handler(it))</p>
<p dir="auto">But it doesn't work beacouse it sends only first value - '0'. How to solve this problem and what is a difference between this freq: tim_a = tim.channel(Timer.A, freq=1000) and this freq: tim_a.freq(5)?</p>
]]></description><link>https://forum.pycom.io/topic/897/timer-and-uart-confugration</link><generator>RSS for Node</generator><lastBuildDate>Wed, 11 Mar 2026 22:02:23 GMT</lastBuildDate><atom:link href="https://forum.pycom.io/topic/897.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 20 Mar 2017 11:51:04 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 11:58:07 GMT]]></title><description><![CDATA[<p dir="auto">Hello,<br />
I want to send radnom values via UART every second. I've got this code:</p>
<p dir="auto">uart = UART(0,  baudrate=115200)</p>
<p dir="auto">def irq_handler(value):<br />
str1 = str(value) + &quot;\r\n&quot;<br />
uart.write(str1)<br />
value += 1</p>
<p dir="auto">tim = Timer(0, mode=Timer.PERIODIC)<br />
tim_a = tim.channel(Timer.A, freq=1000)<br />
tim_a.freq(5)</p>
<p dir="auto">it = 0</p>
<p dir="auto">tim_a.irq(trigger=Timer.TIMEOUT, handler=irq_handler(it))</p>
<p dir="auto">But it doesn't work beacouse it sends only first value - '0'. How to solve this problem and what is a difference between this freq: tim_a = tim.channel(Timer.A, freq=1000) and this freq: tim_a.freq(5)?</p>
]]></description><link>https://forum.pycom.io/post/5404</link><guid isPermaLink="true">https://forum.pycom.io/post/5404</guid><dc:creator><![CDATA[michalt38]]></dc:creator><pubDate>Mon, 20 Mar 2017 11:58:07 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 12:24:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/986">@michalt38</a><br />
use Alarm to fire event in some interval<br />
<a href="https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/timers.html" target="_blank" rel="noopener noreferrer nofollow">https://docs.pycom.io/pycom_esp32/pycom_esp32/tutorial/includes/timers.html</a></p>
]]></description><link>https://forum.pycom.io/post/5407</link><guid isPermaLink="true">https://forum.pycom.io/post/5407</guid><dc:creator><![CDATA[livius]]></dc:creator><pubDate>Mon, 20 Mar 2017 12:24:49 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 13:05:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/199">@livius</a><br />
In this line:</p>
<pre><code>    self.__alarm = Timer.Alarm(self._seconds_handler, 1, periodic=True)
</code></pre>
<p dir="auto">I've got an error: no such attribute. Does it work on WiPy 1?</p>
]]></description><link>https://forum.pycom.io/post/5411</link><guid isPermaLink="true">https://forum.pycom.io/post/5411</guid><dc:creator><![CDATA[michalt38]]></dc:creator><pubDate>Mon, 20 Mar 2017 13:05:35 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 13:17:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/986">@michalt38</a><br />
Ach - you have Wipy 1 - no that samle is for Wipy2 only<br />
I do not know wipy1 - maybe someone else can help you</p>
]]></description><link>https://forum.pycom.io/post/5412</link><guid isPermaLink="true">https://forum.pycom.io/post/5412</guid><dc:creator><![CDATA[livius]]></dc:creator><pubDate>Mon, 20 Mar 2017 13:17:56 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 13:18:24 GMT]]></title><description><![CDATA[<p dir="auto">The documentation for WiPy 1 is here: <a href="http://docs.micropython.org/en/latest/wipy/" target="_blank" rel="noopener noreferrer nofollow">http://docs.micropython.org/en/latest/wipy/</a><br />
and an example on how to use the timer with a callback is here:<br />
<a href="http://docs.micropython.org/en/latest/wipy/wipy/quickref.html" target="_blank" rel="noopener noreferrer nofollow">http://docs.micropython.org/en/latest/wipy/wipy/quickref.html</a></p>
]]></description><link>https://forum.pycom.io/post/5413</link><guid isPermaLink="true">https://forum.pycom.io/post/5413</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Mon, 20 Mar 2017 13:18:24 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 14:32:44 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/98">@robert-hh</a><br />
Ok but what is wrong with my code that it does not work? It's just like in the example you sent. It sends only first value and timer's irq handler does not execute after it.</p>
]]></description><link>https://forum.pycom.io/post/5414</link><guid isPermaLink="true">https://forum.pycom.io/post/5414</guid><dc:creator><![CDATA[michalt38]]></dc:creator><pubDate>Mon, 20 Mar 2017 14:32:44 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 14:38:34 GMT]]></title><description><![CDATA[<p dir="auto">There was a discussion about it and long periods. As far as I recall, the setting should be:</p>
<pre><code>tim = Timer(0, mode=Timer.PERIODIC, width = 32)
tim_a = tim.channel(Timer.A|Timer.B, freq=1)
value = 0
tim_a.irq(trigger=Timer.TIMEOUT, handler=irq_handler())
</code></pre>
<p dir="auto">But the discussion is somewhere buried in this board talk:<br />
<a href="http://forum.micropython.org/viewforum.php?f=11" target="_blank" rel="noopener noreferrer nofollow">http://forum.micropython.org/viewforum.php?f=11</a><br />
Which is anyhow the better place for WiPy 1 question.</p>
<p dir="auto">And you cannot return a value from an irq handler, unless you modify global symbols or class members. The other question is whether you can allocate memory in that handler, which you do by creating str1. Try to send a constant value first, to see, if it's periodic, and if that succeeds, take the next step.</p>
]]></description><link>https://forum.pycom.io/post/5415</link><guid isPermaLink="true">https://forum.pycom.io/post/5415</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Mon, 20 Mar 2017 14:38:34 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 14:42:37 GMT]]></title><description><![CDATA[<p dir="auto">I found a thread about it:<br />
<a href="http://forum.micropython.org/viewtopic.php?f=11&amp;t=2127&amp;p=13811&amp;hilit=Timer.A+Timer.B#p13811" target="_blank" rel="noopener noreferrer nofollow">http://forum.micropython.org/viewtopic.php?f=11&amp;t=2127&amp;p=13811&amp;hilit=Timer.A+Timer.B#p13811</a></p>
]]></description><link>https://forum.pycom.io/post/5416</link><guid isPermaLink="true">https://forum.pycom.io/post/5416</guid><dc:creator><![CDATA[robert-hh]]></dc:creator><pubDate>Mon, 20 Mar 2017 14:42:37 GMT</pubDate></item><item><title><![CDATA[Reply to Timer and UART confugration on Mon, 20 Mar 2017 14:47:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://forum.pycom.io/uid/98">@robert-hh</a> Thanks a lot! :)</p>
]]></description><link>https://forum.pycom.io/post/5417</link><guid isPermaLink="true">https://forum.pycom.io/post/5417</guid><dc:creator><![CDATA[michalt38]]></dc:creator><pubDate>Mon, 20 Mar 2017 14:47:06 GMT</pubDate></item></channel></rss>