[Perf-V Review] + Driver for dot matrix blocks under Hummingbird soft core
[Copy link]
In the Hummingbird softcore DEMO , there is a dot matrix block driving example. Although the dot matrix block models used may not be the same, they can still be unified if the principles are understood.
The dot matrix block I use is LG7088BH , and its pin arrangement is as follows:
LG7088BH
Note: L (column) lights up at low level, H (row) lights up at high level .
The row driving function of the dot matrix block is:
void write_line(int x)
{
GPIO_SET(D7,0,output);
GPIO_SET(JP1_2,0,output);
GPIO_SET(JP1_4,0,output);
GPIO_SET(D4,0,output);
GPIO_SET(D8,0,output);
GPIO_SET(JP1_1,0,output);
GPIO_SET(D9,0,output);
GPIO_SET(D12,0,output);
// High level is valid
if (x==0)
{
GPIO_SET(D7,1,output); //0
}
if (x==1)
{
GPIO_SET(JP1_2,1,output);//1
}
if (x==2)
{
GPIO_SET(JP1_4,1,output); //2
}
if (x==3)
{
GPIO_SET(D4,1,output); //3
}
if (x==4)
{
GPIO_SET(D8,1,output); //4
}
if (x==5)
{
GPIO_SET(JP1_1,1,output); //5
}
if (x==6)
{
GPIO_SET(D9,1,output); //6
}
if (x==7)
{
GPIO_SET(D12,1,output); //7
}
}
From this, we can analyze the connection relationship between H1~H8 and the development board as follows:
H1-D7 H2-JP1-2 H3-JP1-4 H4- D4 H5-D8 H6-JP1-1 H7-D9 H8-D12
When the function is called, only one high level is issued to light up a specified row each time it is called.
The column driver function of the dot matrix block is:
void write_row(int x)
{
GPIO_SET(JP1_3,1,output);
GPIO_SET(D10,1,output);
GPIO_SET(D11,1,output);
GPIO_SET(D6,1,output);
GPIO_SET(D13,1,output);
GPIO_SET(D5,1,output);
GPIO_SET(D1_TX1,1,output);
GPIO_SET(D0_RX1,1,output);
// Low level is valid
if (0x01&table[x]) {
GPIO_SET(JP1_3,0,output);
}
if ((0x01<<1)&table[x])
{
GPIO_SET(D10,0,output);
}
if ((0x01<<2)&table[x])
{
GPIO_SET(D11,0,output);
}
if ((0x01<<3)&table[x])
{
GPIO_SET(D6,0,output);
}
if ((0x01<<4)&table[x])
{
GPIO_SET(D13,0,output);
}
if ((0x01<<5)&table[x])
{
GPIO_SET(D5,0,output);
}
if ((0x01<<6)&table[x])
{
GPIO_SET(D1_TX1,0,output);
}
if ((0x01<<7)&table[x])
{
GPIO_SET(D0_RX1,0,output);
}
}
From this, we can analyze the connection relationship between L1~L8 and the development board as follows:
L1-JP1-3 L2-D10 L3-D11 L4-D6 L5-D13 L6-D5 L7-D1 L8-D0
When the function is called, each time it is called, the columns of the specified row are lit up at a low level.
The character display function of the dot matrix block is:
void letter_display(void)
{
for (x=0;x<8;x++)
{
write_line(x);
write_row(x+skew);
}
}
From this we can analyze that the function of this function is to display the content of one screen each time it is called, a total of 8*8=64 dots .
In addition, since the variable skew is added to the write_row () function , its function is equivalent to an offset that moves between the fonts , so it can produce the effect of displaying characters moving horizontally on the dot matrix block .
The main function of the dot matrix block driver is:
int main(int argc, char **argv)
{
PLIC_init(&g_plic,
PLIC_CTRL_ADDR,
PLIC_NUM_INTERRUPTS,
PLIC_NUM_PRIORITIES);
reset_demo();
while (1){
letter_display(); // Character display
}
return 0;
}
From this, we can analyze that the program maintains the display and produces the subtitle scrolling effect by calling the display function letter_display() .
The method to achieve program download is:
- Open the virtual machine and enter the DEMO_GPIO directory. Then copy the relevant files of the LED dot matrix to the directory to overwrite the original files with the same name, as shown in Figure 1 .
Figure 1 Directory Contents
- Compile the LED matrix code , the instructions are :
make software PROGRAM= demo_gpio BOARD=Perf-V-creative-board
The compiled result is shown in Figure 2 :
Figure 2 Compilation results
- Upload the code , the command used is
make upload PROGRAM= demo_gpio BOARD=Perf-V-creative-board
The result after uploading is shown in Figure 3 :
Figure 3 Complete upload
At this time, the display effect of the dot matrix block is shown in FIG4 .
It is worth pointing out that it seems that none of the four pins of the PMOD interface work properly, resulting in no display in the 2nd , 3rd , 6th columns and the 8th row. You can consider using the A0~A3 pins as a solution instead.
Figure 4 shows the effect
Animation effects:
|