【ESK32-360测评】+基于MX25L64字库构建与使用
本帖最后由 jinglixixi 于 2020-9-2 19:24 编辑<p>1.显示Flash ID</p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"> </span></span></p>
<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:宋体">图</span>1<span style="font-family:宋体">运行效果</span></span></span></p>
<p style="text-align:justify"> </p>
<p>LCD屏显示从W25Q64读取的Flash ID,其程序代码如下:</p>
<pre>
/* Initialize the SPI_FLASH driver */
result = SPI_FLASH_Init();
/* Check the SPI Flash ID */
if (result == TRUE)
{
LCD_StringLineDisplay8(Line1, " W25Q64 TEST OK");
}
else
{
LCD_StringLineDisplay8(Line1, " W25Q64 TEST NO");
}
/* Read SPI Flash ID */
FLASH_ID = SPI_FLASH_ReadJEDECID();
gHelloString = (u8) (FLASH_ID>>28);
gHelloString = (u8) (FLASH_ID>>24)&0x00ff;
gHelloString = (u8) (FLASH_ID>>20)&0x00ff;
gHelloString = (u8) (FLASH_ID>>16)&0x00ff;
gHelloString = (u8) (FLASH_ID>>12)&0x00ff;
gHelloString = (u8) (FLASH_ID>>8)&0x00ff;
gHelloString = (u8) (FLASH_ID>>4)&0x00ff;
gHelloString = (u8) (FLASH_ID&0x00ff);
LCD_StringLineDisplay8(Line2, " Flash ID:");
for(i=0;i<8;i++)
{
u=gHelloString;
HEX();
}</pre>
<p>2.显示读取内容</p>
<p>按下K1键,以读取存储字模 或 读取数组以验证读取正确性。</p>
<p><i></i>图2 读取存储内容</p>
<p> </p>
<p>显示读取内容的程序如下:</p>
<pre>
/* Read WEAKUP and then output to LED1 */
TmpStatus = HT32F_DVB_PBGetState(BUTTON_WAKEUP);
if(TmpStatus)
{
HT32F_DVB_LEDOn(HT_LED1);
LCD_BackColorSet(Black);
LCD_TextColorSet(Yellow);
LCD_StringLineDisplay8(Line8, "Read_");
L=0;
//SPI_FLASH_WriteStatus(0x00);
LCD_BackColorSet(Black);
LCD_TextColorSet(Yellow);
for(i=0;i<8;i++)
{
H=(u8) (ReadDZ>>((7-i)*4)&0x0000000f);
if(H<10)
{
LCD_CharDraw8(Line6, L, H+'0');
}
else
{
LCD_CharDraw8(Line6, L, H-10+'A');
}
L=L+8;
}
SPI_FLASH_BufferRead(Rx_Buffer, 0x1000,320); // 256
for (i = 0; i <320; i++)
{
gHelloString= Rx_Buffer;
}
LCD_BackColorSet(Black);
LCD_TextColorSet(Yellow);
l=0;
for(i=0;i<8;i++)
{
u=gHelloString;
HEX1();
}
l=0;
for(i=0;i<8;i++)
{
u=gHelloString;
HEX2();
}
if(j<320)
{
j=j+16;
ReadDZ=ReadDZ+16;
}
}
else
{
HT32F_DVB_LEDOff(HT_LED1);
}
</pre>
<p>3.存储字模</p>
<p>按F2读取数组中的字模内容写入W25Q64内</p>
<p><i><i><i></i></i></i>图3 写字模到字库</p>
<p> </p>
<p>将字模写到字库的程序如下:</p>
<pre>
/* Read KEY1 and then output to LED2 */
TmpStatus = HT32F_DVB_PBGetState(BUTTON_KEY1);
if(! TmpStatus)
{
result = SPI_FLASH_Init();
if (result == TRUE)
{
LCD_StringLineDisplay8(Line1, " W25Q64 TEST OK");
}
else
{
LCD_StringLineDisplay8(Line1, " W25Q64 TEST NO");
}
/* Clear the Block Protection bit */
SPI_FLASH_SectorErase(0x1000);
for (i = 0; i < 320; i++)
{
gHelloString= Hzk;
Tx_Buffer= gHelloString;
}
SPI_FLASH_BufferWrite(Tx_Buffer, 0x1000,320 ); //256
HT32F_DVB_LEDOn(HT_LED2);
LCD_BackColorSet(Black);
LCD_TextColorSet(Yellow);
LCD_StringLineDisplay8(Line8, "Write");
LCD_BackColorSet(Black);
LCD_TextColorSet(Yellow);
SPI_FLASH_BufferDualRead((u16*)Tx_Buffer,0x1000, 8);
for (i = 0; i < 16; i++)
{
gHelloString= Tx_Buffer;
}
l=0;
for(i=0;i<8;i++)
{
u=gHelloString;
HEX1();
}
l=0;
for(i=0;i<8;i++)
{
u=gHelloString;
HEX2();
}
LCD_StringLineDisplay8(Line8, "OK___");
}
else
{
HT32F_DVB_LEDOff(HT_LED2);
}
</pre>
<p>4.验证显示效果</p>
<p>以红色字体显示字模内容</p>
<p><i><i><i><i><i><i></i></i></i></i></i></i>图4 验证显示</p>
<pre>
/* Read KEY2 and then output to LED3 */
TmpStatus = HT32F_DVB_PBGetState(BUTTON_KEY2);
if(! TmpStatus)
{
LCD_StringLineDisplay8(Line8, "dispL");
SPI_FLASH_BufferRead(Rx_Buffer, 0x1000,320);
for (i = 0; i < 320; i++)
{
gHelloString= Rx_Buffer;
}
for(i=0;i<10;i++)
{
if(i>4)LCD_CharDrawHk(Line5, 176+(i-5)*16, i);
else LCD_CharDrawHk(Line4, 176+i*16, i);
}
LCD_BackColorSet(Black);
LCD_TextColorSet(Yellow);
}
</pre>
<p>至此,本次的测评任务就暂时画上一个句号了,在测评期间出SD卡不支持的原因,超量完成了预期的设定目标,使得开发板用的更加得心应手,ESK32-360开发板是在是一款学习和开发的好工具。再次感谢有这样好的测评活动,也期待能有的HT32F12345测评和使用的机会。</p>
<p>可以试着字库索引和字模文件下发升级,usart或者USB,写入外部flash</p>
宋元浩 发表于 2020-9-2 23:11
可以试着字库索引和字模文件下发升级,usart或者USB,写入外部flash
<p>是的,正在摸索中,主要是文件大的时候,怕不协调而失控。</p>
页:
[1]