当前位置:网站首页>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 :
边栏推荐
- Desktop network error display red ×, Component failed to start
- Flexible scale out: from file system to distributed file system
- Install and initialize MySQL (under Windows)
- How to buy the millions of medical insurance for children? How much is it a year? Which product is the best?
- Getting started and using postman
- From URL to access page rendering
- hashlib. Md5() function to filter out duplicate system files and remove them
- Log4j2 vulnerability detection tool list
- Splunk series: Splunk installation and deployment (I)
- [distributed system design profile (1)] raft
猜你喜欢

Leetcode daily question - 28 Implement strstr() (simple)

One picture to achieve the selected effect
Online yaml to XML tool

Splunk series: Splunk installation and deployment (I)
Section 13: simplify your code with Lombok
[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
[golang] leetcode intermediate - the kth largest element in the array &
HMS core actively explores the function based on hardware ear return, helping to reduce the overall singing delay rate of the singing bar by 60%

After 20 days' interview, I finally joined Ali (share the interview process)
Baidu AI Financing Innovation workshop enrollment!
随机推荐
Flexible scale out: from file system to distributed file system
[machine learning] machine learning from zero to mastery -- teach you to recognize handwritten digits using KNN
Leetcode daily [2022 - 02 - 18]
Popular understanding of deviation and variance in machine learning
Common optimization of e-commerce server system architecture
Chrome plugin installation
How does jest expose specific problems in complex judgment conditions?
[phase 23] phased summary of spring recruitment practice (Alibaba cloud has OC)
Several methods of obtaining function annotation text on pycharm
Cloud native 04: use envoy + open policy agent as the pre agent
A new paradigm for large model application: unified feature representation optimization (UFO)
2022 "gold, silver and four" is a must for job hopping. You must know 100 questions in 2022 intermediate and advanced Android interview to realize your big factory dream
laf. JS - open source cloud development framework (readme.md)
Analysis and cleaning of kdevtmpfsi virus content
The beginning of manjaro's journey
Lesson 1 Preparation
Lesson 4 beautifulsoup
Instant aesthetics of the Centennial Olympic Games: beauty in the air, condensed in minutes and seconds - Alibaba cloud video cloud AI editorial department "cloud smart scissors"
Interface automation -md5 password encryption
Yunzhisheng atlas supercomputing platform: computing acceleration practice based on fluid + alluxio (Part 2)