2189 views|2 replies

1452

Posts

1

Resources
The OP
 

[AT32F421 review] + Display driver for digital tube module [Copy link]

 This post was last edited by jinglixixi on 2021-4-30 08:42

Last time we introduced a digital tube display module with parallel transmission. This time we will introduce another digital tube display module that transmits data in serial mode, as shown in Figure 1.

In addition to the power pin, the module has 3 pins, namely the DIN data pin, the CLK clock pin and the CS selection pin.

Figure 1 Digital tube module

The display effect of the digital tube is shown in Figure 2. If the pin connection relationship is modified, the digital tube module can be directly connected to the Arduino interface for use.

Figure 2 Digital tube module

The relevant procedures are as follows:

#include <stdio.h>

#include "at32f4xx.h"

#include "at32_board.h"

#define SMG_CLK_Set() GPIOB->BSRE = GPIO_Pins_9

#define SMG_CLK_Clr() GPIOB->BRE = GPIO_Pins_9

#define SMG_DIN_Set() GPIOB->BSRE = GPIO_Pins_8

#define SMG_DIN_Clr() GPIOB->BRE = GPIO_Pins_8

#define SMG_CS_Set() GPIOB->BSRE = GPIO_Pins_10

#define SMG_CS_Clr() GPIOB->BRE = GPIO_Pins_10

void AT_eval_smg_init(void)

{

GPIO_InitType GPIO_InitStructure;

RCC_AHBPeriphClockCmd(RCC_AHBPERIPH_GPIOB, ENABLE);

GPIO_StructInit(&GPIO_InitStructure);

GPIO_InitStructure.GPIO_Pins = GPIO_Pins_10|GPIO_Pins_8|GPIO_Pins_9;

GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;

GPIO_InitStructure.GPIO_OutType = GPIO_OutType_PP;

GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_10MHz;

GPIO_Init(GPIOB, &GPIO_InitStructure);

SMG_CLK_Set();

SMG_DIN_Set();

SMG_CS_Set();

}

void Write_Max7219_byte(uint8_t DATA)

{

uint8_t i;

SMG_CS_Clr();

for(i=8;i>=1;i--)

{

SMG_CLK_Clr();

if(DATA&0x80)

{

SMG_DIN_Set();

}

else

{

SMG_DIN_Clr();

}

DATA=DATA<<1;

SMG_CLK_Set();

}

}

void Init_MAX7219(void)

{

Write_Max7219(0x09, 0xff);

Write_Max7219(0x0a, 0x03);

Write_Max7219(0x0b, 0x07);

Write_Max7219(0x0c, 0x01);

Write_Max7219(0x0f, 0x01);

}

int main(void)

{

AT32_Board_Init();

AT_eval_smg_init();

Init_MAX7219();

Delay_ms(2000);

Write_Max7219(0x0f,0x00);

Write_Max7219(1,8);

Write_Max7219(2,7);

Write_Max7219(3,6);

Write_Max7219(4,5);

Write_Max7219(5,4);

Write_Max7219(6,3);

Write_Max7219(7,2);

Write_Max7219(8,1);

for(;;)

{

AT32_LEDn_Toggle(LED2);

Delay_ms(200);

AT32_LEDn_Toggle(LED3);

Delay_ms(200);

AT32_LEDn_Toggle(LED4);

Delay_ms(200);

}

}

Figure 3 Digital tube module

The pin connections and high and low level output settings to achieve the effect of Figure 3 are as follows:

DIN--- PA5

CS---PA6

CLK---PA7

#define SMG_CLK_Set() GPIOA->BSRE = GPIO_Pins_7

#define SMG_CLK_Clr() GPIOA->BRE = GPIO_Pins_7

#define SMG_DIN_Set() GPIOA->BSRE = GPIO_Pins_5

#define SMG_DIN_Clr() GPIOA->BRE = GPIO_Pins_5

#define SMG_CS_Set() GPIOA->BSRE = GPIO_Pins_6

#define SMG_CS_Clr() GPIOA->BRE = GPIO_Pins_6

This post is from Domestic Chip Exchange

Latest reply

Expert~  Details Published on 2021-5-7 16:57
 
 

693

Posts

7

Resources
2
 

666

This post is from Domestic Chip Exchange
 
 
 

266

Posts

0

Resources
3
 
Expert~
This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list