jinglixixi 发表于 2020-9-2 12:21

【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">&nbsp;</p>

<p>LCD屏显示从W25Q64读取的Flash ID,其程序代码如下:</p>

<pre>
&nbsp; &nbsp;&nbsp;/* Initialize the SPI_FLASH driver */
&nbsp;&nbsp; &nbsp;result = SPI_FLASH_Init();
&nbsp;&nbsp;&nbsp; /* Check the SPI Flash ID&nbsp;&nbsp;&nbsp; */
&nbsp; &nbsp;&nbsp;if (result == TRUE)
&nbsp;&nbsp; &nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LCD_StringLineDisplay8(Line1, &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; W25Q64 TEST OK&quot;);
&nbsp;&nbsp; &nbsp;}
&nbsp;&nbsp; &nbsp;else
&nbsp;&nbsp; &nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LCD_StringLineDisplay8(Line1, &quot;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;W25Q64 TEST NO&quot;);
&nbsp;&nbsp; &nbsp;}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* Read SPI Flash ID&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;FLASH_ID = SPI_FLASH_ReadJEDECID();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&gt;&gt;28);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&gt;&gt;24)&amp;0x00ff;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&gt;&gt;20)&amp;0x00ff;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&gt;&gt;16)&amp;0x00ff;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&gt;&gt;12)&amp;0x00ff;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&gt;&gt;8)&amp;0x00ff;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&gt;&gt;4)&amp;0x00ff;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; gHelloString = (u8) (FLASH_ID&amp;0x00ff);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LCD_StringLineDisplay8(Line2, &quot;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;Flash ID:&quot;);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for(i=0;i&lt;8;i++)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; u=gHelloString;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HEX();
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</pre>

<p>2.显示读取内容</p>

<p>按下K1键,以读取存储字模 或 读取数组以验证读取正确性。</p>

<p><i></i>图2&nbsp;读取存储内容</p>

<p>&nbsp;</p>

<p>显示读取内容的程序如下:</p>

<pre>

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/* Read WEAKUP and then output to LED1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */
&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TmpStatus = HT32F_DVB_PBGetState(BUTTON_WAKEUP);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if(TmpStatus)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;HT32F_DVB_LEDOn(HT_LED1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LCD_BackColorSet(Black);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LCD_TextColorSet(Yellow);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LCD_StringLineDisplay8(Line8, &quot;Read_&quot;);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;L=0;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //SPI_FLASH_WriteStatus(0x00);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LCD_BackColorSet(Black);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LCD_TextColorSet(Yellow);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;for(i=0;i&lt;8;i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; H=(u8) (ReadDZ&gt;&gt;((7-i)*4)&amp;0x0000000f);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   if(H&lt;10)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LCD_CharDraw8(Line6, L, H+&#39;0&#39;);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   else
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;LCD_CharDraw8(Line6, L, H-10+&#39;A&#39;);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;       }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      L=L+8;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;   SPI_FLASH_BufferRead(Rx_Buffer, 0x1000,320);&nbsp; // 256
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      for (i = 0; i &lt;320; i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      {
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;gHelloString= Rx_Buffer;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      }
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;   &nbsp;LCD_BackColorSet(Black);
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      LCD_TextColorSet(Yellow);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      &nbsp;l=0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      for(i=0;i&lt;8;i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;       &nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;    u=gHelloString;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;   &nbsp;HEX1();
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      }
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;   l=0;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      for(i=0;i&lt;8;i++)
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;      u=gHelloString;
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; HT32F_DVB_LEDOff(HT_LED1);
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
                  </pre>

<p>3.存储字模</p>

<p>按F2读取数组中的字模内容写入W25Q64内</p>

<p><i><i><i></i></i></i>图3 &nbsp;写字模到字库</p>

<p>&nbsp;</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, &quot;          W25Q64 TEST OK&quot;);
            }
            else
            {
                          LCD_StringLineDisplay8(Line1, &quot;          W25Q64 TEST NO&quot;);
            }
                        /* Clear the Block Protection bit      */
                        SPI_FLASH_SectorErase(0x1000);
                   for (i = 0; i &lt; 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, &quot;Write&quot;);
                        LCD_BackColorSet(Black);
            LCD_TextColorSet(Yellow);       
       
                        SPI_FLASH_BufferDualRead((u16*)Tx_Buffer,0x1000, 8);
                for (i = 0; i &lt; 16; i++)
            {
               gHelloString= Tx_Buffer;
            }
                        l=0;
                        for(i=0;i&lt;8;i++)
                {
                     u=gHelloString;
                   HEX1();
                }
                        l=0;
                for(i=0;i&lt;8;i++)
                {
                     u=gHelloString;
                   HEX2();
                }
                       
                        LCD_StringLineDisplay8(Line8, &quot;OK___&quot;);
               }
               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 &nbsp;验证显示</p>

<pre>

         /* Read KEY2 and then output to LED3    */
         TmpStatus = HT32F_DVB_PBGetState(BUTTON_KEY2);
         if(! TmpStatus)
               {
                  LCD_StringLineDisplay8(Line8, &quot;dispL&quot;);       
                        SPI_FLASH_BufferRead(Rx_Buffer, 0x1000,320);
                for (i = 0; i &lt; 320; i++)
            {
                  gHelloString= Rx_Buffer;
            }
                       
                  for(i=0;i&lt;10;i++)
                {
                                   if(i&gt;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>

宋元浩 发表于 2020-9-2 23:11

<p>可以试着字库索引和字模文件下发升级,usart或者USB,写入外部flash</p>

jinglixixi 发表于 2020-9-3 08:09

宋元浩 发表于 2020-9-2 23:11
可以试着字库索引和字模文件下发升级,usart或者USB,写入外部flash

<p>是的,正在摸索中,主要是文件大的时候,怕不协调而失控。</p>
页: [1]
查看完整版本: 【ESK32-360测评】+基于MX25L64字库构建与使用