3657 views|14 replies

1452

Posts

1

Resources
The OP
 

【AT32F421 Review】+ Display driver for OLED screen [Copy link]

 
 

The AT32F421 development board is equipped with an Arduino interface, which greatly facilitates the expansion of peripherals and functions. For example, we can use its I2C interface to drive the display of the OLED screen, and the display effect is shown in the figure.

Since the I2C interface on the board is misaligned with the pin connection of the OLED screen, the problem can be solved in minutes by using GPIO to simulate I2C.

OLED screen display effect

The connection relationship between the OLED screen and the MCU is:

SCL---PB9

SDA--PB8

The relevant definition statements for the pin output high and low levels are as follows:

#define OLED_SCLK_Set() GPIOB->BSRE = GPIO_Pins_9

#define OLED_SCLK_Clr() GPIOB->BRE = GPIO_Pins_9

#define OLED_SDIN_Set() GPIOB->BSRE = GPIO_Pins_8

#define OLED_SDIN_Clr() GPIOB->BRE = GPIO_Pins_8

The pin output function setting function of the OLED screen is:

void AT32_OLED_Init(void)
{
 GPIO_InitType GPIO_InitStructure;
 RCC_AHBPeriphClockCmd(RCC_AHBPERIPH_GPIOB, ENABLE);
 GPIO_StructInit(&GPIO_InitStructure);
 GPIO_InitStructure.GPIO_Pins = GPIO_Pins_8|GPIO_Pins_9;
 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
 GPIO_InitStructure.GPIO_OutType = GPIO_OutType_PP;
 GPIO_InitStructure.GPIO_Pull = GPIO_Pull_NOPULL;
 GPIO_InitStructure.GPIO_MaxSpeed = GPIO_MaxSpeed_50MHz;
 GPIO_Init(GPIOB, &GPIO_InitStructure);
}

The corresponding string output function is:

void OLED_ShowCHinese(uint8_t x, uint8_t y, uint8_t no)
{
 uint8_t t,adder=0;
 OLED_Set_Pos(x,y);
 for(t=0;t<16;t++)
 {
 OLED_WR_Byte(Hzk[2*no][t],OLED_DATA);
 adder+=1;
 }
 OLED_Set_Pos(x,y+1);
 for(t=0;t<16;t++)
 {
 OLED_WR_Byte(Hzk[2*no+1][t],OLED_DATA);
 adder+=1;
 }
}

The main program to realize string display is:

int main(void)
{
 AT32_Board_Init();
 AT32_OLED_Init();
 OLED_Init();
 OLED_Clear();
 OLED_ShowString(0,0,"AT32F421 TEST",16);
 OLED_ShowString(0,2,"OLED DISPLAY",16);
 for(;;)
 {
 AT32_LEDn_Toggle(LED2);
 Delay_ms(200);
 AT32_LEDn_Toggle(LED3);
 Delay_ms(200);
 AT32_LEDn_Toggle(LED4);
 Delay_ms(200);
}
}

This post is from Domestic Chip Exchange

Latest reply

  Details Published on 2021-4-13 17:02

赞赏

1

查看全部赞赏

 
 

2w

Posts

74

Resources
2
 

Good, it seems that the Arduino interface is necessary.

This post is from Domestic Chip Exchange
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle

Comments

Yes, it works well with peripherals.  Details Published on 2021-4-12 10:37
Personal signature

加油!在电子行业默默贡献自己的力量!:)

 
 
 

1452

Posts

1

Resources
3
 
soso posted on 2021-4-12 09:30 Good, it seems that the Arduino interface is necessary.

Yes, it works well with peripherals.

This post is from Domestic Chip Exchange
 
 
 

693

Posts

7

Resources
4
 

Can the display be displayed vertically? Like a bracelet display

This post is from Domestic Chip Exchange

Comments

This should be no problem, just transpose the font display.  Details Published on 2021-4-12 12:47
 
 
 

1452

Posts

1

Resources
5
 
bqgup posted on 2021-4-12 11:35 Can the display screen be displayed vertically? Like the display of a bracelet

This should be no problem, just transpose the font display.

This post is from Domestic Chip Exchange
 
 
 

1942

Posts

2

Resources
6
 

Not bad, IIC driver is really good~

This post is from Domestic Chip Exchange

Comments

Yes, it only uses one more pin than LED, but its information expression is much stronger.  Details Published on 2021-4-13 09:20
 
 
 

7422

Posts

2

Resources
7
 

Thank you for sharing. I2C is not complicated and is a must-have project for practice.

This post is from Domestic Chip Exchange

Comments

Yes, the use of gadgets like OLED screen is the second only to LED lighting as a GPIO port testing method, but it is more powerful than LED.  Details Published on 2021-4-13 09:17
Personal signature

默认摸鱼,再摸鱼。2022、9、28

 
 
 

6547

Posts

0

Resources
8
 

The pin connection between the I2C interface and the OLED screen is misaligned

Is it a small mistake in the board design?

This post is from Domestic Chip Exchange

Comments

This is not the case. It is mainly because the pin arrangement of the OLED screen is not very suitable for the characteristics of the Arduino interface.  Details Published on 2021-4-13 09:11
 
 
 

71

Posts

2

Resources
9
 

I heard that the IIC of STM32 has some problems. I don't know how it works for Arteli. Has the OP encountered this?

This post is from Domestic Chip Exchange

Comments

For the convenience of using pins, I rarely use hardware I2C to drive peripherals directly. It’s just that the usage habits are different, but it’s good as long as I can realize the functions I need.  Details Published on 2021-4-13 09:15
 
 
 

1452

Posts

1

Resources
10
 
Jacktang posted on 2021-4-12 22:44 Is the misalignment of the pin connection between the I2C interface and the OLED screen a small mistake in the board design?

This is not the case. It is mainly because the pin arrangement of the OLED screen is not very suitable for the characteristics of the Arduino interface.

This post is from Domestic Chip Exchange
 
 
 

1452

Posts

1

Resources
11
 
This post was last edited by jinglixixi on 2021-4-14 08:14
Albert.G posted on 2021-4-13 08:41 I heard that STM32's own IIC has some problems. I wonder how it works for Arteli. Has the OP encountered this?

For the convenience of using pins, I seldom use hardware I2C to drive peripherals directly. It’s just that the usage habits are different, but it’s good as long as I can realize the functions I need.

This post is from Domestic Chip Exchange
 
 
 

1452

Posts

1

Resources
12
 
freebsder posted on 2021-4-12 22:41 Thank you for sharing. I2C is not complicated and is a must-have project for practice.

Yes, the use of gadgets like OLED screen is the second only to LED lighting as a GPIO port testing method, but it is more powerful than LED.

This post is from Domestic Chip Exchange
 
 
 

1452

Posts

1

Resources
13
 
w494143467 posted on 2021-4-12 16:28 Not bad, IIC driver is really good~

Yes, it only uses one more pin than LED, but its information expression is much stronger.

This post is from Domestic Chip Exchange
 
 
 

1236

Posts

66

Resources
14
 

This post is from Domestic Chip Exchange
 
 
 

1452

Posts

1

Resources
15
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

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