[Xiaohua HC32F448 Review] +W25Q64 reading, writing and application
[Copy link]
HC32F448 is equipped with 256KB Flash memory, which can support image data storage of TFT screen. However, to realize multiple image storage like digital photo frame, it needs the cooperation of board W25Q64.
The circuit of W25Q64 is shown in Figure 1, which occupies 6 pins in total.
Figure 1 W25Q64 circuit
The connection relationship between the pins of W25Q64 is:
SCK---PB14
NSS---PC7 (pin overlap)
IO0---P B13
IO1---PD9
IO2---PD10
IO3---PD11
In order to use the read and write functions of W25Q64, the configured TFT display screen is shown in Figure 2. It is directly connected using the LCD screen interface on the development board, so it can save the trouble of wiring and effectively improve the reliability of the display.
Figure 2 Display screen connected to development board
The connection relationship of each pin of the TFT screen is:
BLK:PB10
SCK:PA12
DSI:PC4
DC:PE12
RST:PE14
CS: PC7
Through observation, it can be found that there are cases where pins are overlapped, but after actual testing it will not affect normal use.
The main program to realize W25Q64 image storage and image reproduction is:
int32_t main(void)
{
int32_t i,j,w;
LL_PERIPH_WE(EXAMPLE_PERIPH_WE);
Init_TFT();
tft_Init();
BACK_COLOR=RED;
POINT_COLOR=WHITE;
LCD_Clear(RED);//YELLOW
LCD_ShowString(80,10,"HC32F448");
LCD_ShowString(80,40,"2.2' TFT");
LCD_DrawLine(0,60, 239, 60);
LCD_DrawLine(0,290, 239, 290);
LCD_ShowString(80,295,"jinglixixi");
BSP_CLK_Init();
BSP_W25QXX_Init();
LL_PERIPH_WP(EXAMPLE_PERIPH_WP);
LoadData();
w=0;
for(j=0;j<7;j++)
{
w=j*4096;
(void)BSP_W25QXX_EraseSector(w);
}
for(j=0;j<7;j++)
{
w=j*4096;
(void)BSP_W25QXX_Write(w+SPI_FLASH_ADDR, gImage_fj+w, SPI_FLASH_DATA_SIZE);
(void)BSP_W25QXX_Write(w+SPI_FLASH_ADDR+2048,gImage_fj+2048+w, SPI_FLASH_DATA_SIZE);
}
Address_set(40,150,199,229);
for(j=0;j<6;j++)
{
w=j*4096;
(void)BSP_W25QXX_Read(w+SPI_FLASH_ADDR, m_au8ReadData, SPI_FLASH_DATA_SIZE);
for(i=0;i<1024;i++)
{
LCD_WR_DATA8(m_au8ReadData[+i*2]);
LCD_WR_DATA8(m_au8ReadData[i*2+1]);
}
(void)BSP_W25QXX_Read(w+SPI_FLASH_ADDR+2048, m_au8ReadData, SPI_FLASH_DATA_SIZE);
for(i=0;i<1024;i++)
{
LCD_WR_DATA8(m_au8ReadData[i*2]);
LCD_WR_DATA8(m_au8ReadData[i*2+1]);
}
}
w=6*4096;
(void)BSP_W25QXX_Read(w+SPI_FLASH_ADDR, m_au8ReadData, SPI_FLASH_DATA_SIZE);
for(i=0;i<512;i++)
{
LCD_WR_DATA8(m_au8ReadData[+i*2]);
LCD_WR_DATA8(m_au8ReadData[i*2+1]);
}
LCD_ShowString(80,70,"W25Q16");
while(1);
}
After the program is compiled and downloaded, the display effect is shown in Figure 3, indicating that the functional design is normal and effective.
Similarly, the construction of the photo gallery and the realization of the digital photo frame function can be realized.
Figure 3 Image reproduction
|