当前位置:网站首页>OLED屏幕的使用
OLED屏幕的使用
2022-07-06 20:22:00 【Kshine2017】
1. 0.96寸7引脚OLED屏幕
- 圖中文字的缺失部分是因為手機拍照所致,實際是完整的文字。
- 參考鏈接:
https://wenku.baidu.com/view/eb67b928b91aa8114431b90d6c85ec3a87c28b86.html
https://wenku.baidu.com/view/11e968518d9951e79b89680203d8ce2f00666590.html - 引脚解釋:
GND GND
VDD VCC 3.3V~5V
PE5 D0 CLK時鐘信息(SCL) SPI_CLK
PE6 D1 數據端口(SDA) SPI_MOSI
PE7 RES 複比特 普通IO
PE8 DC 數據/命令選擇(D/C) 普通IO
PE9 CS 片選,低電平有效 SPI_CS

- 電阻的接選方式如下圖,對應4線SPI。

- IO模擬4線SPI,驅動OLED
void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {
0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOD_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIOA->BSRR = OLED_DC_Pin;
GPIOA->BSRR = OLED_RES_Pin;
GPIOA->BSRR = GPIO_PIN_5;//SCK拉高
GPIOA->BSRR = GPIO_PIN_7;//拉高
//CS引脚直接接了GND
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Pin = OLED_DC_Pin|OLED_RES_Pin;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
}
#define MOSI_H GPIOA->BSRR = GPIO_PIN_7 //HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7, GPIO_PIN_SET) //
#define MOSI_L GPIOA->BRR = GPIO_PIN_7 //HAL_GPIO_WritePin(GPIOA, GPIO_PIN_7, GPIO_PIN_RESET) //
#define SCK_H GPIOA->BSRR = GPIO_PIN_5 //HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_SET) //
#define SCK_L GPIOA->BRR = GPIO_PIN_5 //HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET) //
//#define MISO
#define NSS_H
#define NSS_L
void delayUS(uint32_t nus)
{
uint16_t i;
for(i=0;i<nus;i++)
{
}
}
//可以使用SPI的方式 HAL_SPI_Transmit(&hspi1,&data,1,1);
void My_SPI_Transmit(unsigned char data)
{
unsigned char i; //定義變量
for(i = 0; i < 8; i++) //循環8次
{
SCK_L;
delayUS(1);
if(data&0x80)
MOSI_H;
else
MOSI_L;
data<<=1;
delayUS(1);
SCK_H;
delayUS(1);
}
}
實測,單片機工作在72MHz的情况下,上述My_SPI_Transmit函數耗費的時間大概是76.4微秒。

驅動文件
https://download.csdn.net/download/Kshine2017/85519013
边栏推荐
- Jupyter launch didn't respond after Anaconda was installed & the web page was opened and ran without execution
- 夏志刚介绍
- Database specific interpretation of paradigm
- Qinglong panel white screen one key repair
- An East SMS login resurrection installation and deployment tutorial
- 腾讯架构师首发,2022Android面试笔试总结
- 01 basic introduction - concept nouns
- Unity writes a timer tool to start timing from the whole point. The format is: 00:00:00
- Special topic of rotor position estimation of permanent magnet synchronous motor -- fundamental wave model and rotor position angle
- golang的超时处理使用技巧
猜你喜欢

New generation garbage collector ZGC

【每周一坑】正整数分解质因数 +【解答】计算100以内质数之和

Ideas and methods of system and application monitoring

Maximum likelihood estimation and cross entropy loss

5. Wireless in vivo nano network: top ten "feasible?" problem

"Penalty kick" games

beegfs高可用模式探讨

Web security - payload

Rhcsa Road

某东短信登录复活 安装部署教程
随机推荐
8086指令码汇总表(表格)
Node. Js: express + MySQL realizes registration, login and identity authentication
Cesium 点击绘制圆形(动态绘制圆形)
Function optimization and arrow function of ES6
Tencent Android development interview, basic knowledge of Android Development
Tips for web development: skillfully use ThreadLocal to avoid layer by layer value transmission
新一代垃圾回收器—ZGC
Crawler (14) - scrape redis distributed crawler (1) | detailed explanation
【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
Unity making plug-ins
8086 instruction code summary (table)
【每周一坑】正整数分解质因数 +【解答】计算100以内质数之和
B-jiege's tree (pressed tree DP)
Web security - payload
JS get browser system language
Wonderful coding [hexadecimal conversion]
Unity makes AB package
Problems encountered in using RT thread component fish
BeagleBoneBlack 上手记
beegfs高可用模式探讨