【MCXN947开发板测评】点阵板显示驱动
<div class='showpostmsg'><p>新年即将来临,为了烘托热烈的气氛,使用点阵板是个不错的选择,这里所用的是一款P4.75型的红色点阵板,其显示分辨率为16*64像素点,见图1所示。</p><p> </p>
<p>图1 点阵板外观</p>
<p > </p>
<p >该点阵板与开发板间是通过接口J1和J2来连接,如图2所示,具体的连接关系为:</p>
<p >CLK---P0_25</p>
<p >LR1---P0_26</p>
<p >LEN---P0_24</p>
<p >LSTB---P0_27</p>
<p >LA---P0_10</p>
<p >LB---P0_28</p>
<p >LC---P0_31</p>
<p >LD---P1_2</p>
<p > </p>
<p > </p>
<p>图2 所用接口</p>
<p > </p>
<p >为输出高低电平所定义的语句为:</p>
<p >#define CLK_high GPIO_PortSet(GPIO0, 1U << 25U) //CLK</p>
<p >#define CLK_low GPIO_PortClear(GPIO0, 1U << 25U)</p>
<p > </p>
<p >#define LR1_high GPIO_PortSet(GPIO0, 1U << 26U) //DIN</p>
<p >#define LR1_low GPIO_PortClear(GPIO0, 1U << 26U)</p>
<p > </p>
<p >#define LEN_high GPIO_PortSet(GPIO0, 1U << 24U) //RES</p>
<p >#define LEN_low GPIO_PortClear(GPIO0, 1U << 24U)</p>
<p > </p>
<p >#define LSTB_high GPIO_PortSet(GPIO0, 1U << 27U) //DC</p>
<p >#define LSTB_low GPIO_PortClear(GPIO0, 1U << 27U)</p>
<p > </p>
<p >#define LA_high GPIO_PortSet(GPIO0, 1U << 10U) //LA</p>
<p >#define LA_low GPIO_PortClear(GPIO0, 1U << 10U)</p>
<p > </p>
<p >#define LB_high GPIO_PortSet(GPIO0, 1U << 28U) //LB</p>
<p >#define LB_low GPIO_PortClear(GPIO0, 1U << 28U)</p>
<p > </p>
<p >#define LC_high GPIO_PortSet(GPIO0, 1U << 31U) //LC</p>
<p >#define LC_low GPIO_PortClear(GPIO0, 1U << 31U)</p>
<p > </p>
<p >#define LD_high GPIO_PortSet(GPIO1, 1U << 2U) //LD</p>
<p >#define LD_low GPIO_PortClear(GPIO1, 1U << 2U)</p>
<p > </p>
<p >使用字模提取软件所构建的数组为:</p>
<p >uint8_t tab[]={</p>
<p >//蛇(0) 年(1) 祥(2) 瑞(3)</p>
<p >0x20,0x10,0x10,0x10,0x10,0x10,0xFE,0x7D,0x02,0x55,0x04,0x56,0x80,0x54,0x88,0x54,</p>
<p >0x90,0x7C,0xA0,0x50,0xC0,0x10,0x82,0x14,0x82,0x1E,0x82,0xE2,0x7E,0x40,0x00,0x00,/*"蛇",0*/</p>
<p >0x00,0x10,0x00,0x10,0xFC,0x1F,0x80,0x20,0x80,0x20,0x80,0x40,0xF8,0x1F,0x80,0x10,</p>
<p >0x80,0x10,0x80,0x10,0xFE,0xFF,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,/*"年",1*/</p>
<p >0x04,0x21,0x84,0x10,0x88,0x10,0x00,0xF8,0xFE,0x0B,0x20,0x10,0x20,0x10,0xFC,0x39,</p>
<p >0x20,0x54,0x20,0x90,0xFE,0x13,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,0x20,0x10,/*"祥",2*/</p>
<p >0x20,0x00,0x22,0x02,0x22,0xFA,0x22,0x22,0xFE,0x23,0x00,0x20,0xFE,0x27,0x20,0xF8,</p>
<p >0x40,0x20,0xFE,0x23,0x52,0x22,0x52,0x3A,0x52,0xE2,0x52,0x42,0x52,0x02,0x06,0x02,/*"瑞",3*/</p>
<p >};</p>
<p > </p>
<p >向点阵板发送字节数据的函数为:</p>
<pre>
<code class="language-cpp">void OutByte(uint16_t dat)
{
uint8_t i=0 ;
for(i=0;i<16;i++)
{
CLK_low;
if(dat&0x8000)
{
LR1_high;
}
else
{
LR1_low;
}
dat=dat<< 1;
CLK_high;
}
}
</code></pre>
<p>点阵板列输出的函数为:</p>
<pre>
<code class="language-cpp">void DisCol(int16_t lenght)
{
int16_t dat,n;
int8_t m=0;
while(lenght--)
{
dat=( tab<<8)+ tab ;
OutByte(dat);
m=m+1;
}
}
</code></pre>
<p>显示输出的函数为:</p>
<pre>
<code class="language-cpp">voidDisplay(void)
{
DisCol(4);
LEN_high;
LSTB_high;
LSTB_low;
SeleRow(ScanRow);
LEN_low;
ScanRow++;
if(ScanRow>15)ScanRow=0;
}
</code></pre>
<p>实现显示效果的主程序为:</p>
<pre>
<code class="language-cpp">int main(void)
{
uint8_t i,n,f,m,j;
uint16_t k;
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput,
0,
};
gpio_pin_config_t key_config = {
kGPIO_DigitalInput,
0,
};
CLOCK_SetClkDiv(kCLOCK_DivFlexcom4Clk, 1u);
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
CLOCK_EnableClock(kCLOCK_Gpio0);
CLOCK_EnableClock(kCLOCK_Gpio1);
BOARD_InitPins();
BOARD_InitBootClocks();
BOARD_InitDebugConsole();
GPIO_PinInit(GPIO0, 25U, &led_config);
GPIO_PinInit(GPIO0, 26U, &led_config);
GPIO_PinInit(GPIO0, 24U, &led_config);
GPIO_PinInit(GPIO0, 27U, &led_config);
GPIO_PinInit(GPIO0, 10U, &led_config);
GPIO_PinInit(GPIO0, 28U, &led_config);
GPIO_PinInit(GPIO0, 31U, &led_config);
GPIO_PinInit(GPIO1, 2U, &led_config);
GPIO_PinInit(GPIO0, 6U, &key_config);
ScanRow=0;
while (1)
{
Display()
delay(2);
}
}
</code></pre>
<p>经程序的编译与下载,其显示效果如图3所示。</p>
<p> </p>
<p>图3 汉字显示效果</p>
<p> </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> <p>感谢支持,蛇年吉祥!!!</p>
akaz 发表于 2025-1-19 15:05
使用点阵板是个不错的选择,这里所用的是一款P4.75型的红色点阵板,其显示分辨率为16*64像素点
<p>没错!!!</p>
页:
[1]