3.4.1 定时器示例
<p>本例仍然使用demo固件</p>
<p>使用前请先确保宏定义DEMO_TIMER已经打开,在头文件<code>wm_demo.h</code>中设置,如下:</p>
<pre><code class="language-c">#define DEMO_TIMER (DEMO_ON && DEMO_CONSOLE)</code></pre>
<p>固件运行后,串口发送命令<code>t-timer()</code>即可执行定时器功能示例,定时器每隔2秒触发一次,输出信息:“timer irq”,如下图所示:</p>
<p><img src="https://www.showdoc.com.cn/server/api/attachment/visitFile?sign=12ddd741c26ff236a6b63e75699f3a3b&file=file.png" alt="" /></p>
<p>定时器源码位于文件<code>wm_timer_demo.c</code>中,其中调用了sdk提供的函数:<code>tls_timer_create</code>创建了一个硬件定时器,每隔2秒产生一次中断,然后输出了“timer irq”</p>