【MM32 eMiniBoard测评】+ SysTick秒计时器
<p>在MM32 eMiniBoard开发板的程序中,配有Systick的相关函数,将它与OLED屏相结合,就可实现一个秒计时器,其运行效果图所示。</p><p></p>
<p>运行效果图</p>
<p> </p>
<p>Systick的相关函数如下:</p>
<pre>
<code class="language-cpp">void Systick_init()
{
if (SysTick_Config(RCC_GetSysClockFreq() / 1000)) {
// Capture error
while (1);
}
// Configure the SysTick handler priority
NVIC_SetPriority(SysTick_IRQn, 0x0);//SysTickinterrupt priority class set
}
void SysTick_Handler(void)
{
Counter++;
if(Counter >= 1000) {
Counter = 0;
s++;
LED1_TOGGLE();
LED2_TOGGLE();
LED3_TOGGLE();
LED4_TOGGLE();
}
}</code></pre>
<p>实现秒计时器的主程序为:</p>
<pre>
<code class="language-cpp">s32 main(void)
{
Systick_init();
LED_Init();
APP_OLED_Init();
OLED_Init();
OLED_Clear();
OLED_ShowString(0,0,"MM32F0133 ",16);
OLED_ShowString(0,2,"SysTick test",16);
OLED_ShowString(0,4,"t = s",16);
while(1) {
OLED_ShowNum(32,4,s,2,16);
}
}</code></pre>
<p> </p>
<p>cortex这些东西挺方便</p>
<p><strong><a href="https://bbs.eeworld.com.cn/elecplay/content/145" target="_blank">灵动MM32 eMiniBoard开发板测评</a></strong></p>
<p>汇总贴:<a href="https://bbs.eeworld.com.cn/thread-1146791-1-1.html" target="_blank">https://bbs.eeworld.com.cn/thread-1146791-1-1.html</a></p>
页:
[1]