1.显示Flash ID
图1运行效果
LCD屏显示从W25Q64读取的Flash ID,其程序代码如下:
/* 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[0] = (u8) (FLASH_ID>>28); gHelloString[1] = (u8) (FLASH_ID>>24)&0x00ff; gHelloString[2] = (u8) (FLASH_ID>>20)&0x00ff; gHelloString[3] = (u8) (FLASH_ID>>16)&0x00ff; gHelloString[4] = (u8) (FLASH_ID>>12)&0x00ff; gHelloString[5] = (u8) (FLASH_ID>>8)&0x00ff; gHelloString[6] = (u8) (FLASH_ID>>4)&0x00ff; gHelloString[7] = (u8) (FLASH_ID&0x00ff); LCD_StringLineDisplay8(Line2, " Flash ID:"); for(i=0;i<8;i++) { u=gHelloString; HEX(); }
2.显示读取内容
按下K1键,以读取存储字模 或 读取数组以验证读取正确性。
显示读取内容的程序如下:
/* 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[i+j]; HEX1(); } l=0; for(i=0;i<8;i++) { u=gHelloString[8+i+j]; HEX2(); } if(j<320) { j=j+16; ReadDZ=ReadDZ+16; } } else { HT32F_DVB_LEDOff(HT_LED1); }
3.存储字模
按F2读取数组中的字模内容写入W25Q64内
将字模写到字库的程序如下:
/* 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[i/16][i%16]; 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[8+i]; HEX2(); } LCD_StringLineDisplay8(Line8, "OK___"); } else { HT32F_DVB_LEDOff(HT_LED2); }
4.验证显示效果
以红色字体显示字模内容
/* 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); }
至此,本次的测评任务就暂时画上一个句号了,在测评期间出SD卡不支持的原因,超量完成了预期的设定目标,使得开发板用的更加得心应手,ESK32-360开发板是在是一款学习和开发的好工具。再次感谢有这样好的测评活动,也期待能有的HT32F12345测评和使用的机会。
本帖最后由 jinglixixi 于 2020-9-2 19:24 编辑引用: 宋元浩 发表于 2020-9-2 23:11 可以试着字库索引和字模文件下发升级,usart或者USB,写入外部flash
是的,正在摸索中,主要是文件大的时候,怕不协调而失控。