2513 views|2 replies

1w

Posts

16

Resources
The OP
 

[NUCLEO-L452RE Review] + Pin drive 1.3-inch OLED and use it to display the number of tasks [Copy link]

Whenever I want to make a screen display, I will look for a screen with few pins and easy to drive. I originally wanted to use a real SPI driver, but there is no pin as fast as that.

I think I'll do it in two steps, and work on the hardware later... I don't know when, but probably in winter.

Let me talk about my screen first.

Here is the SPI specification:

Why can't I add it? It should be in the attachment. 01-规格书+驱动芯片手册.zip (3.27 MB, downloads: 2)

Then add the pins you need: I use PA11, PA12, PB11, PB12, power and ground are not counted, just plug it in.

Then, create the entire OLED file as an OLED subdirectory and put it in the root directory of this program.

In the oled.h file, change the definition of the pin, and the initialization is automatically completed in STM32CUBEMX

//-----------------OLED端口定义----------------  					   
#define OLED_SCLK_Clr() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_RESET);//GPIO_ResetBits(GPIOB,GPIO_Pins_12)//CLK
#define OLED_SCLK_Set() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_12, GPIO_PIN_SET);//GPIO_SetBits(GPIOB,GPIO_Pins_12)

#define OLED_SDIN_Clr() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET);//GPIO_ResetBits(GPIOB,GPIO_Pins_13)//DIN
#define OLED_SDIN_Set() HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_SET);//GPIO_SetBits(GPIOB,GPIO_Pins_13)

#define OLED_RST_Clr() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_RESET);//GPIO_ResetBits(GPIOB,GPIO_Pins_14)//RES
#define OLED_RST_Set() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_12, GPIO_PIN_SET);//GPIO_SetBits(GPIOB,GPIO_Pins_14)

#define OLED_DC_Clr() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);//GPIO_ResetBits(GPIOB,GPIO_Pins_15)//DC
#define OLED_DC_Set() HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);//GPIO_SetBits(GPIOB,GPIO_Pins_15)

Then include this header file in the main function. When initializing, be sure to connect each pin to high level immediately after initialization. This took me half a day.

//OLED_CS_Clr();  //打开片选使能
	OLED_SCLK_Set()
	OLED_SDIN_Set()
	OLED_RST_Set();
	HAL_Delay(1);
	 OLED_RST_Clr();
	HAL_Delay(20);
	OLED_RST_Set();
	HAL_Delay(20);
	//OLED_BLK_Set();
	
//************* Start Initial Sequence **********// 
LCD_WR_REG(0x36); 
LCD_WR_DATA8(0x00);

LCD_WR_REG(0x3A); 
LCD_WR_DATA8(0x05);

LCD_WR_REG(0xB2);
LCD_WR_DATA8(0x0C);
LCD_WR_DATA8(0x0C);
LCD_WR_DATA8(0x00);
LCD_WR_DATA8(0x33);
LCD_WR_DATA8(0x33);

LCD_WR_REG(0xB7); 
LCD_WR_DATA8(0x35);  

LCD_WR_REG(0xBB);
LCD_WR_DATA8(0x19);

LCD_WR_REG(0xC0);
LCD_WR_DATA8(0x2C);

LCD_WR_REG(0xC2);
LCD_WR_DATA8(0x01);

LCD_WR_REG(0xC3);
LCD_WR_DATA8(0x12);   

LCD_WR_REG(0xC4);
LCD_WR_DATA8(0x20);  

LCD_WR_REG(0xC6); 
LCD_WR_DATA8(0x0F);    

LCD_WR_REG(0xD0); 
LCD_WR_DATA8(0xA4);
LCD_WR_DATA8(0xA1);

LCD_WR_REG(0xE0);
LCD_WR_DATA8(0xD0);
LCD_WR_DATA8(0x04);
LCD_WR_DATA8(0x0D);
LCD_WR_DATA8(0x11);
LCD_WR_DATA8(0x13);
LCD_WR_DATA8(0x2B);
LCD_WR_DATA8(0x3F);
LCD_WR_DATA8(0x54);
LCD_WR_DATA8(0x4C);
LCD_WR_DATA8(0x18);
LCD_WR_DATA8(0x0D);
LCD_WR_DATA8(0x0B);
LCD_WR_DATA8(0x1F);
LCD_WR_DATA8(0x23);

LCD_WR_REG(0xE1);
LCD_WR_DATA8(0xD0);
LCD_WR_DATA8(0x04);
LCD_WR_DATA8(0x0C);
LCD_WR_DATA8(0x11);
LCD_WR_DATA8(0x13);
LCD_WR_DATA8(0x2C);
LCD_WR_DATA8(0x3F);
LCD_WR_DATA8(0x44);
LCD_WR_DATA8(0x51);
LCD_WR_DATA8(0x2F);
LCD_WR_DATA8(0x1F);
LCD_WR_DATA8(0x1F);
LCD_WR_DATA8(0x20);
LCD_WR_DATA8(0x23);

LCD_WR_REG(0x21); 

LCD_WR_REG(0x11); 
//Delay (120); 

LCD_WR_REG(0x29); 
 

At first, there is no initial value set for the pin, so it can't be driven. I tried for a long time but couldn't figure it out. I changed the pin definition and the clock to the clock divided by 4, but it still didn't work.

Finally, I added an initial value and it was done.

Add a variable to the default task and then display it. There is no meaning, just display it.

Another bad thing about STM32CUBEMX is that once it is reset, the previously defined settings are gone.

Now if I want to complete the previous tasks, I have to refer to the previous posts and build them up slowly.

Here are the photos:

How should I put it? In the future, I will use the FREERTOS of the display department. This time, I uploaded the OLED package so that I won't be lost next time.

OLED.rar (10.17 KB, downloads: 0)

This post is from stm32/stm8

Latest reply

Thank you for sharing, looking forward to the follow-up!   Details Published on 2020-12-29 22:37
Personal signaturehttp://shop34182318.taobao.com/
https://shop436095304.taobao.com/?spm=a230r.7195193.1997079397.37.69fe60dfT705yr
 

1w

Posts

204

Resources
2
 

ST NUCLEO-L452RE review

Summary post: https://bbs.eeworld.com.cn/thread-1151850-1-1.html

This post is from stm32/stm8
Add and join groups EEWorld service account EEWorld subscription account Automotive development circle
 
Personal signature

玩板看这里:

https://bbs.eeworld.com.cn/elecplay.html

EEWorld测评频道众多好板等你来玩,还可以来频道许愿树许愿说说你想要玩的板子,我们都在努力为大家实现!

 

7462

Posts

2

Resources
3
 

Thank you for sharing, looking forward to the follow-up!

This post is from stm32/stm8
 
Personal signature

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

 

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