[Yichuang ET6001 Review] Serial digital tube display driver
[Copy link]
I originally planned to use the GPIO port to implement an I2C interface OLED screen display, but after several unsuccessful debugging attempts, I had to give up this option.
Therefore, the serial digital tube display module was selected as a breakthrough, and its display effect was good after testing.
The display module uses MAX7219 as the main control chip, can display 8-bit values, and supports cascading. In addition to the power supply, it only needs 3 GPIO ports, so it saves pin resources.
Figure 1 Serial digital tube display module
The connection relationship between the display module and the development board is:
SCL---GPIO2_2
SDA---GPIO2_3
CS---GPIO2_4
In order to provide high and low level outputs to the serial digital tube display module, the defined statements are:
#define CLK_SetLow GPIO_WritePin(GPIO2, GPIO_PIN_02, RESET)
#define CLK_SetHigh GPIO_WritePin(GPIO2, GPIO_PIN_02, SET)
#define DIN_SetLow GPIO_WritePin(GPIO2, GPIO_PIN_03, RESET)
#define DIN_SetHigh GPIO_WritePin(GPIO2, GPIO_PIN_03, SET)
#define CS_SetLow GPIO_WritePin(GPIO2, GPIO_PIN_04, RESET)
#define CS_SetHigh GPIO_WritePin(GPIO2, GPIO_PIN_04, SET)
Since the key chip used in the serial digital tube display module is MAX7219, a function for serially sending byte data is configured for it, and its content is:
static void Write_Max7219_byte(char DATA)
{
char i;
CS_SetLow;
delay(10);
for(i=8;i>=1;i--)
{
CLK_SetLow;
if(DATA&0x80)
DIN_SetHigh;
else
DIN_SetLow;
delay(10);
DATA=(char)(DATA<<1);
CLK_SetHigh;
delay(10);
}
}
Based on the function Write_Max7219_byte(), the function that sends data to the specified address is:
static void Write_Max7219(char address,char dat)
{
CS_SetLow;
Write_Max7219_byte(address);
Write_Max7219_byte(dat);
CS_SetHigh;
}
For the serial digital tube display module, its initialization function is:
static void Init_MAX7219(void)
{
Write_Max7219(0x09, 0xff);
Write_Max7219(0x0a, 0x02);
Write_Max7219(0x0b, 0x07);
Write_Max7219(0x0c, 0x01);
Write_Max7219(0x0f, 0x00);
}
To test the serial digital tube display module, the corresponding main program is:
int main(void)
{
EVB_LEDInit();
Init_MAX7219();
Write_Max7219(1,1);
Write_Max7219(2,2);
Write_Max7219(3,3);
Write_Max7219(4,4);
Write_Max7219(5,5);
Write_Max7219(6,6);
Write_Max7219(7,7);
Write_Max7219(8,8);
while (1)
{
GPIO_TogglePin(GPIO_LED_PORT, GPIO_LED_PIN);
__Delay(0x5FFFFF);
}
}
After the program is compiled and run, the effect is shown in Figure 2.
Figure 2 Display effect diagram
In this way, the display driver of the serial digital tube module is realized, and it can be used to complete the numerical display later.
|