jinglixixi 发表于 2023-6-3 12:03

【N32WB031_STB开发板测评】+点阵屏显示驱动与电子计时牌

<div class='showpostmsg'><p>前面介绍过一种8x8点阵屏的显示驱动,但要显示一些信息就需要将多个模块级联起来。然而采用这种级联方案,在价格方面是不划算的。为此就选用一款红色的P4.75点阵屏来替代它,该点阵屏的规格为16*64点阵,其外观如图1所示。</p>

<p> &nbsp;图1 点阵屏外观</p>

<p >该点阵屏采用的接口方式为HUB08,各引脚的名称如图2所示。</p>

<p >&nbsp; 图2&nbsp; HUB08接口</p>

<p>&nbsp;</p>

<p >该点阵屏与开发板的连接关系为:</p>

<p >A---PB9</p>

<p >B---PB8</p>

<p >C---PA6</p>

<p >D---PA5</p>

<p >R1 ---PA0</p>

<p >OE ---PA1</p>

<p >LAT ---PA2</p>

<p >CLK---PA3</p>

<p >使用相关引脚输出高低电平的语句定义为:</p>

<p >#define LR1_high&nbsp;&nbsp; GPIO_SetBits(GPIOA, GPIO_PIN_0)</p>

<p >#define LR1_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOA, GPIO_PIN_0)</p>

<p >#define CLK_high&nbsp;&nbsp; GPIO_SetBits(GPIOA, GPIO_PIN_3)</p>

<p >#define CLK_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOA, GPIO_PIN_3)</p>

<p >#define LA_high&nbsp;&nbsp; GPIO_SetBits(GPIOB, GPIO_PIN_9)</p>

<p >#define LA_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOB, GPIO_PIN_9)</p>

<p >#define LB_high&nbsp;&nbsp; GPIO_SetBits(GPIOB, GPIO_PIN_8)</p>

<p >#define LB_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOB, GPIO_PIN_8)</p>

<p >#define LC_high&nbsp;&nbsp; GPIO_SetBits(GPIOA, GPIO_PIN_6)</p>

<p >#define LC_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOA, GPIO_PIN_6)</p>

<p >#define LD_high&nbsp;&nbsp; GPIO_SetBits(GPIOA, GPIO_PIN_5)</p>

<p >#define LD_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOA, GPIO_PIN_5)</p>

<p >#define LEN_high&nbsp;&nbsp; GPIO_SetBits(GPIOA, GPIO_PIN_1)</p>

<p >#define LEN_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOA, GPIO_PIN_1)</p>

<p >#define LSTB_high&nbsp;&nbsp; GPIO_SetBits(GPIOA, GPIO_PIN_2)</p>

<p >#define LSTB_low&nbsp;&nbsp;&nbsp; GPIO_ResetBits(GPIOA, GPIO_PIN_2)</p>

<p >对相关引脚进行工作模式配置的函数为:</p>

<pre>
<code class="language-cpp">void gpio_Init(void)
{
    GPIO_InitType GPIO_InitStructure;
    RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOB, ENABLE);
    GPIO_InitStruct(&amp;GPIO_InitStructure);
    GPIO_InitStructure.Pin =GPIO_PIN_8|GPIO_PIN_9;
    GPIO_InitStructure.GPIO_Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitPeripheral(GPIOB, &amp;GPIO_InitStructure);
        RCC_EnableAPB2PeriphClk(RCC_APB2_PERIPH_GPIOA, ENABLE);
        GPIO_InitStructure.Pin =GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_5|GPIO_PIN_6;
        GPIO_InitPeripheral(GPIOA, &amp;GPIO_InitStructure);
}
</code></pre>

<p>&nbsp;</p>

<p>点阵屏发送数据的函数为:</p>

<pre>
<code class="language-cpp">void OutByte(uint16_t dat)
{
    uint8_t i=0 ;
    for(i=0;i&lt;16;i++)
    {
      CLK_low;
      if(dat&amp;0x8000)
      {
            LR1_high;
      }
      else
      {
            LR1_low;
      }
      dat=dat&lt;&lt;1;
      CLK_high;
    }
}
</code></pre>

<p>&nbsp;</p>

<p>发送多列数据的函数为:</p>

<pre>
<code class="language-cpp">voidDisCol(uint16_t dat,uint16_t len)
{
    while(len--)
    {
               OutByte(dat);
    }
}
</code></pre>

<p>&nbsp;</p>

<p>输出行地址的函数为:</p>

<pre>
<code class="language-cpp">voidSeleRow(uint8_t Nd)
{
    uint8_t N;
        N=Nd;
        N=N%16;
    if(N&amp;0x01)   LA_high;
    elseLA_low;
    if (N&amp;0x02)LB_high;
    elseLB_low;
    if (N&amp;0x04)LC_high;
    elseLC_low;
    if (N&amp;0x08)LD_high;
    elseLD_low;
}
</code></pre>

<p>&nbsp;</p>

<p>检测驱动测试的显示函数为:</p>

<pre>
<code class="language-cpp">voidDisplay(void)
{
          DisCol(0x5555,4);
          LEN_high;
          LSTB_high;
          LSTB_low;
      SeleRow(ScanRow);
      LEN_low;
      ScanRow++;
          if(ScanRow&gt;15)ScanRow=0;
}
</code></pre>

<p>&nbsp;</p>

<p>实现图3所示效果的主程序为:</p>

<pre>
<code class="language-cpp">int main(void)
{
        gpio__Init();
        ScanRow=0;
    while(1)
    {
               Display();
    }
}
</code></pre>

<p>&nbsp;</p>

<p> 图3测试效果</p>

<p>&nbsp;</p>

<p >为实现数字符号的显示,需使用字模提取软件来获得相应的字模,其存储结构为:</p>

<p >uint8_t S[]={</p>

<p >0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*&quot;0&quot;,0*/</p>

<p >0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,/*&quot;1&quot;,1*/</p>

<p >0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,/*&quot;2&quot;,2*/</p>

<p >0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,/*&quot;3&quot;,3*/</p>

<p >0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00,/*&quot;4&quot;,4*/</p>

<p >0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,/*&quot;5&quot;,5*/</p>

<p >0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*&quot;6&quot;,6*/</p>

<p >0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,/*&quot;7&quot;,7*/</p>

<p >0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,/*&quot;8&quot;,8*/</p>

<p >0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,/*&quot;9&quot;,9*/</p>

<p >0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,/*&quot;:&quot;,10*/</p>

<p >0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*&quot;-&quot;,11*/</p>

<p >0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,</p>

<p >};</p>

<p align="left" >相应的显示测试函数为:</p>

<pre>
<code class="language-cpp">void DisCol(uint16_t lenght)    // 显示数字
{
    uint16_t dat;
    uint8_t m=8;
    while(lenght--)
    {
               dat=(V&lt;&lt;8)+V;
               OutByte(dat);
               m=m+1;
    }
}
</code></pre>

<p>&nbsp;</p>

<p align="left">如果将它与RTC计时功能结合起来,就可实现一个具有电子时钟功能的点阵信息牌,其显示效果如图4所示。</p>

<p align="left"> 图4 显示效果</p>

<p align="left">&nbsp;</p>

<p >演示视频:</p>

<p >2dc5688fc437d1ded4e139fde92e742d<br />
&nbsp;</p>

<p >&nbsp;</p>

<p align="left">&nbsp;</p>

<p>&nbsp;</p>
</div><script>                                        var loginstr = '<div class="locked">查看本帖全部内容,请<a href="javascript:;"   style="color:#e60000" class="loginf">登录</a>或者<a href="https://bbs.eeworld.com.cn/member.php?mod=register_eeworld.php&action=wechat" style="color:#e60000" target="_blank">注册</a></div>';
                                       
                                        if(parseInt(discuz_uid)==0){
                                                                                                (function($){
                                                        var postHeight = getTextHeight(400);
                                                        $(".showpostmsg").html($(".showpostmsg").html());
                                                        $(".showpostmsg").after(loginstr);
                                                        $(".showpostmsg").css({height:postHeight,overflow:"hidden"});
                                                })(jQuery);
                                        }                </script><script type="text/javascript">(function(d,c){var a=d.createElement("script"),m=d.getElementsByTagName("script"),eewurl="//counter.eeworld.com.cn/pv/count/";a.src=eewurl+c;m.parentNode.insertBefore(a,m)})(document,523)</script>

lugl4313820 发表于 2023-6-3 21:10

李老师的作品,按步部班,每个作品都是学习的精品,感谢分享!

jinglixixi 发表于 2023-6-4 22:17

lugl4313820 发表于 2023-6-3 21:10
李老师的作品,按步部班,每个作品都是学习的精品,感谢分享!

<p>感谢支持!!!</p>

lkh747566933 发表于 2023-6-6 14:01

李老师的作品,按步部班,每个作品都是学习的精品,感谢分享!

jinglixixi 发表于 2023-6-6 15:54

lkh747566933 发表于 2023-6-6 14:01
李老师的作品,按步部班,每个作品都是学习的精品,感谢分享!

<p>感谢支持!!!</p>
页: [1]
查看完整版本: 【N32WB031_STB开发板测评】+点阵屏显示驱动与电子计时牌