OLED display based on IIC and SPI protocol

1. Understand SPI

1. Definition of SPI

SPI (Serial Peripheral Interface) is a serial peripheral interface.
SPI is a high-speed, full-duplex, synchronous communication bus, and only occupies four wires on the pins of the chip, saving the pins of the chip. SPI is a ring bus structure consisting of ss(cs), sck, sdi, and sdo. The timing is mainly under the control of sck, and two bidirectional shift registers perform data exchange.
Send on rising edge, receive on falling edge, send high bit first.
When the rising edge comes, the level on sdo will be sent to the register of the slave device.
When the falling edge comes, the level on sdi will be received into the register of the master device.

2. SPI connection method

insert image description here
SS (Slave Select) : Slave device selection signal line, often called chip selection signal line.
SCK (Serial Clock) : Clock signal line, used for communication data synchronization.
MOSI (Master Output, Slave Input) : Master output/slave input pin.
MISO (Master Input, Slave Output) : master input/slave output pin.

2. Use 0.96-inch OLED display to display data

1. Run the demo program given by the merchant

Download link
http://www.lcdwiki.com/res/Program/OLED/0.96inch/SPI_SSD1306_MSP096X_V1.0/0.96inch_SPI_OLED_Module_SSD1306_MSP096X_V1.0.zip
(data link source https://blog.csdn.net/qq_43279579/article/details /111414037 )
After downloading the data package, run the corresponding keil code of the chip.

2. Connect the development board and display

The connection method is as follows
insert image description here

3. Running results

insert image description here

3. Modify the program by yourself to realize the display

First, use software to generate text codes,
as shown in the figure

"李",0x01,0x00,0x01,0x00,0x7F,0xFC,0x03,0x80,0x05,0x40,0x09,0x20,0x31,0x18,0xC1,0x06,
0x0F,0xE0,0x00,0x40,0x00,0x80,0xFF,0xFE,0x01,0x00,0x01,0x00,0x05,0x00,0x02,0x00,
"欢",0x00,0x80,0x00,0x80,0xFC,0x80,0x04,0xFC,0x05,0x04,0x49,0x08,0x2A,0x40,0x14,0x40,
0x10,0x40,0x28,0xA0,0x24,0xA0,0x45,0x10,0x81,0x10,0x02,0x08,0x04,0x04,0x08,0x02,

Implement display code

void TEST_MainPage(void)
{
    
    	
	GUI_ShowString(28,0,"lihuan",16,1);//英文姓名
	GUI_ShowCHinese(28,20,16,"李欢",1);//中文姓名
	GUI_ShowString(4,48,"632007030418",16,1);//数字详细
	delay_ms(1500);		
	delay_ms(1500);
}

main function

int main(void)
{
    
    	
	delay_init();	    	       //延时函数初始化	  
	OLED_Init();			         //初始化OLED  
	OLED_Clear(0);             //清屏(全黑)
	while(1) 
	{
    
    	
		TEST_MainPage();         //界面显示
	}
}

Save and debug to generate a hex file, and burn it into the chip, the display will show

4. Display the results

insert image description here

5. Reference

https://blog.csdn.net/qq_43279579/article/details/111414037

Guess you like

Origin blog.csdn.net/qq_54761976/article/details/127664506