当前位置:网站首页>OLED driven learning based on ssd1306 (II): addressing mode of ssd1306
OLED driven learning based on ssd1306 (II): addressing mode of ssd1306
2022-06-25 20:49:00 【CharX】
SPI Communication program :( Clock high idle , The rising edge reads data , From high to low )
void OLED_WR_Byte(u8 data,u8 cmd){
unsigned char i = 0;
if(cmd){//cmd Nonzero ,DC pull up , Write data mode
OLED_DC_High;
}
else{// Write command mode
OLED_DC_Low;
}
/**********SPI The main body ***********/
for(i=0;i<8;i++){
OLED_SCL_Low;
if(data & 0x80){
OLED_SDA_High;
}
else{
OLED_SDA_Low;
}
OLED_SCL_High;
data <<= 0x01;
}
OLED_SCL_High;
/*****************************/
}SSD1306 Introduction to addressing mode :
| Addressing mode selection command : 0x20
Optional mode : ( Page address 0x10, level 0x00, vertical 0x01)
- 0x02: Page address addressing mode

In this mode , The monitor starts from a page column0→column127 scan , It should be noted that in this mode, the column address will automatically after receiving a write video memory command +1 however When the page is scanned to the ending column address, the pointer will return to the starting address of the page and the page address pointer will not automatically +1, This means that we need to manually select the page address in our program
Code example :( Write video memory function )
void OLED_Refresh(void){
u8 i,j;
for(i = 0;i<8;i++){
OLED_WR_Byte(0xb0+i,OLED_WR_CMD);//
OLED_WR_Byte(0x00,OLED_WR_CMD);
OLED_WR_Byte(0x10,OLED_WR_CMD);
for(j = 0;j<128;j++){
OLED_WR_Byte(OLED_GDDRAM[j][i],OLED_WR_DATA);
}
}
}Write data together except full screen , You can also select a specified area for writing , Similar to the code above :
(: Official documents

That is, in the normal display mode , Page address addressing mode , When writing to video memory, you need to specify the starting address of the column first , Page address .
- Set the lower four bits of the column address :0x00-0x0F
- Set the upper four bits of the column address :0x10-0x1F
- Set page address command :0xB0-0xBF(PAGE0-PAGE7)
Take the example in the official document for analysis :
command 0xB2 Set the page to be written to PAGE2; Low four digit command 0x03 And the senior four 0x00( The command sent is 0x10) Together they make up the address 0x03, From SEG3 Start writing to video memory .
For example :
1. Let's send the order first 0xB0,0x00,0x11, Then the write start position is pointed to PAGE2 Of SEG32(0x10)
2. send data 0101 0010B, that (SEG32,PAGE2) From top to bottom 2 individual , The first 5 individual , The first 7 A dot matrix is lit , After completion, the column address is automatically +1, That is, the video memory write position has reached (SEG33,PAGE2), If we send the data again, it will be written (SEG33,PAGE2). To advance , Until the write position reaches (SEG127,PAGE2) after , The next write position will return to (SEG32,PAGE2), If we want to continue writing to the next page, we need to send command 0xB3(0xB0-0xBF, Any one ) And specify the starting column address .
- 0x00 Horizontal address addressing mode

This mode is in the page address addressing mode, and the page address automatically when the column address reaches the end +1, When both the column address and the page address reach the end , Both the column address and the page address are reset automatically
// Write video memory function
void OLED_Refresh(void){
u8 i,j;
for(i = 0;i<8;i++){
for(j = 0;j<128;j++){
OLED_WR_Byte(OLED_GDDRAM[j][i],OLED_WR_DATA);
}
}
}- 0x01 Vertical address addressing mode

Vertical addressing mode , seeing the name of a thing one thinks of its function , As opposed to horizontal addressing mode . Pictured above :
In the above horizontal address addressing mode and vertical address addressing mode , You cannot use the positioning command in page addressing mode , But it has its own commands :
- Set column address command 0x21
- Set page address command 0x22
Column address setting command (0x21)
The column address setting command consists of three commands , The first order is 0x21, the second , The third command sets the column start and end addresses respectively
(0x00-0x7F and 0x00-0x7F)
Page address setting command (0x22)
The page address setting command, like the column address setting command, consists of three commands :
0x22->(0x00-0x07)->(0x00-0x07)
(: Examples of official documents
In the example, the :
The starting column address is Col2, Terminate as Col125(0x21->0x02->0x7D);
The starting page address is PAGE1, The address of the termination page is PAGE2(0x22->0x01->0x06);
The addressing address is in horizontal addressing mode , Write the diagram as above :
边栏推荐
- The beginning of manjaro's journey
- Cloud development practice of the small program for brushing questions in the postgraduate entrance examination - page design and production (home page of the question bank, ranking page, my)
- Cvpr2020 | the latest cvpr2020 papers are the first to see, with all download links attached!
- Detailed explanation of unified monitoring function of multi cloud virtual machine
- Share several Threat Intelligence platforms
- Yunzhisheng atlas supercomputing platform: computing acceleration practice based on fluid + alluxio (Part 2)
- 5 minutes to learn how to install MySQL
- Bank digital transformation layout in the beginning of the year, 6 challenges faced by financial level structure and Countermeasures
- Leetcode daily question - 28 Implement strstr() (simple)
- Barrier of cursor application scenario
猜你喜欢

One picture to achieve the selected effect
[data recovery in North Asia] a data recovery case in which the upper virtual machine data is lost due to the hard disk failure and disconnection of raid6 disk array
New generation engineers teach you how to play with alluxio + ml (Part 2)

Install and initialize MySQL (under Windows)
A new paradigm for large model application: unified feature representation optimization (UFO)

Installing mysql8 under centos8
Day 28/100 CI CD basic introductory concepts

Log4j2 vulnerability detection tool list
Online yaml to XML tool

1.1-mq visual client preliminary practice
随机推荐
Desktop network error display red ×, Component failed to start
How to play one to many in JPA?
Nine built-in objects of JSP and four scopes of Servlet
2022年启牛学堂证券开户安全嘛?
The super easy-to-use test tool sorted out by Ali P8 for a week
Record some questions about MySQL (DNS reverse resolution in Linux)
"Space guard soldier" based on propeller -- geosynchronous geostationary orbit space target detection system
Exploration of advanced document editor design in online Era
What is machine learning? (Fundamentals)
An unusual interview question: why doesn't the database connection pool adopt IO multiplexing?
Uncover n core 'black magic' of Presto + alluxio
COMP9024
IPtables
Online yaml to XML tool
Splunk series: Splunk data import (II)
[deep learning series] - visual interpretation of neural network
How can the intelligent transformation path of manufacturing enterprises be broken due to talent shortage and high cost?
What are the differences between domestic advanced anti DDoS servers and overseas advanced anti DDoS servers?
Barrier of cursor application scenario
SaaS privatization deployment scheme