jinglixixi 发表于 2024-11-23 21:20

【翌创ET6001测评】点阵板显示驱动

<p>在通常的情况下,我们所用的显示器件多为数码管、液晶屏等。但在公共场合,则需要使用较大尺寸和规格的显示器件。</p>

<p >市场上的告广牌多是由半板拼接而成的,这里就选用一款P4.75的红色点阵板,其显示分辨率为16*64像素点,其外观如图1所示。</p>

<p>在通常的情况下,我们所用的显示器件多为数码管、液晶屏等。但在公共场合,则需要使用较大尺寸和规格的显示器件。</p>

<p >市场上的告广牌多是由半板拼接而成的,这里就选用一款P4.75的红色点阵板,其显示分辨率为16*64像素点,其外观如图1所示。</p>

<p > &nbsp;</p>

<p>图1 点阵屏外观</p>

<p >&nbsp;</p>

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

<p > &nbsp;</p>

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

<p >&nbsp;</p>

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

<p >A&nbsp;&nbsp;---- P24</p>

<p >B&nbsp;&nbsp;---- P11</p>

<p >C&nbsp;&nbsp;---- P12</p>

<p >D&nbsp;&nbsp;----P13</p>

<p >R1 ---- P23</p>

<p >CLK----P22</p>

<p >EN ---- P21</p>

<p >STB---- P25</p>

<p >&nbsp;</p>

<p >所用引脚的工作模式配置函数为:</p>

<pre>
<code class="language-cpp">static void dzp_CONFIG(void)
{
    IOC_Init_TypeDef init;
    IOC_ConfigStructInit(&amp;init);
    init.mode = IOC_AF_MODE_3;
    init.dir = GPIO_DIR_OUT;
    init.pull = IOC_PULL_NONE;
    IOC_Config(IOC_PIN_GPIO_PLL_REF, &amp;init);
    GPIO_PortOutputEnable(GPIO2, GPIO_PIN_01);
    GPIO_PortOutputEnable(GPIO2, GPIO_PIN_02);
    GPIO_PortOutputEnable(GPIO2, GPIO_PIN_03);
    GPIO_PortOutputEnable(GPIO2, GPIO_PIN_04);
    GPIO_PortOutputEnable(GPIO2, GPIO_PIN_05);
    GPIO_PortOutputEnable(GPIO1, GPIO_PIN_01);
    GPIO_PortOutputEnable(GPIO1, GPIO_PIN_02);
    GPIO_PortOutputEnable(GPIO1, GPIO_PIN_03);
}</code></pre>

<p >&nbsp;</p>

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

<p >#define LR1_high &nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_03, SET) &nbsp;&nbsp;&nbsp;</p>

<p >#define LR1_low &nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_03, RESET)</p>

<p >&nbsp;</p>

<p >#define CLK_high &nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_02, SET)</p>

<p >#define CLK_low &nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_02, RESET)</p>

<p >&nbsp;</p>

<p >#define LSTB_high &nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_05, SET)</p>

<p >#define LSTB_low &nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_05, RESET)</p>

<p >&nbsp;</p>

<p >#define LEN_high &nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_01, SET)</p>

<p >#define LEN_low &nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_01, RESET)</p>

<p >&nbsp;</p>

<p >#define LA_high &nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_04, SET)</p>

<p >#define LA_low &nbsp;&nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO2, GPIO_PIN_04, RESET)</p>

<p >&nbsp;</p>

<p >#define LB_high &nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO1, GPIO_PIN_01, SET)</p>

<p >#define LB_low &nbsp;&nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO1, GPIO_PIN_01, RESET)</p>

<p >&nbsp;</p>

<p >#define LC_high &nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO1, GPIO_PIN_02, SET)</p>

<p >#define LC_low &nbsp;&nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO1, GPIO_PIN_02, RESET)</p>

<p >&nbsp;</p>

<p >#define LD_high &nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO1, GPIO_PIN_03, SET)</p>

<p >#define LD_low &nbsp;&nbsp;&nbsp;&nbsp;GPIO_WritePin(GPIO1, GPIO_PIN_03, RESET)</p>

<p >&nbsp;</p>

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

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

<p>&nbsp;</p>

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

<pre>
<code class="language-cpp">static void DisCol(uint16_t lenght)
{
    uint16_t dat;
    uint8_t m=0;
    while(lenght--)
    {
         dat=(S*16+ScanRow]&lt;&lt;8)+S*16+ScanRow];
         OutByte(dat);
         m=m+2;
    }
}</code></pre>

<p>&nbsp;</p>

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

<pre>
<code class="language-cpp">static void  SeleRow(uint8_t Nd)
{
    uint8_t N;
    N=Nd;
    N=N%16;
    if(N&amp;0x01)   LA_high;
    else  LA_low;
    if (N&amp;0x02)  LB_high;
    else  LB_low;
    if (N&amp;0x04)  LC_high;
    else  LC_low;
    if (N&amp;0x08)  LD_high;
    else  LD_low;
}</code></pre>

<p>&nbsp;</p>

<p>实现显示输出的函数为:</p>

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

<p>&nbsp;</p>

<p>模拟RTC计时效果的显示函数为:</p>

<pre>
<code class="language-cpp">static void ShowTime(void)
{
    sj= 1;
    sj= 2;
        sj= 10;
    sj= 3;
    sj= 0;
        sj= 10;
    sj= 0;
    sj= 8;
    Display();
}</code></pre>

<p>&nbsp;</p>

<p>为进行显示,所配置的字模由数组来存储,其内容为:</p>

<pre>
<code class="language-cpp">uint8_t S[]={
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*"0",0*/
0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,/*"1",1*/
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,/*"2",2*/
0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,/*"3",3*/
0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00,/*"4",4*/
0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,/*"5",5*/
0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00,/*"6",6*/
0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,/*"7",7*/
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,/*"8",8*/
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,/*"9",9*/
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,/*":",10*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"-",11*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};</code></pre>

<p>&nbsp;</p>

<p>实现显示输出的主程序为:</p>

<pre>
<code class="language-cpp">int32_t main(void)
{
    dzp_CONFIG();
    ScanRow=0;
    while (1)
    {
         ShowTime();
    }
}</code></pre>

<p>&nbsp;</p>

<p>经程序的编译与运行,其执行效果如图3所示。</p>

<p> &nbsp;</p>

<p>图3&nbsp; 硬件连接及显示效果</p>
页: [1]
查看完整版本: 【翌创ET6001测评】点阵板显示驱动