当前位置:网站首页>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
边栏推荐
- Cesium 两点之间的直线距离
- 5. 無線體內納米網:十大“可行嗎?”問題
- Tencent cloud database public cloud market ranks top 2!
- Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model
- 腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒
- Cesium Click to draw a circle (dynamically draw a circle)
- B-杰哥的树(状压树形dp)
- BUUCTF---Reverse---easyre
- Gui Gui programming (XIII) - event handling
- Basic knowledge of lists
猜你喜欢

【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN

Le lancement du jupyter ne répond pas après l'installation d'Anaconda
![[cloud native and 5g] micro services support 5g core network](/img/c9/4ccacd1e70285c2ceb50c324e5018c.png)
[cloud native and 5g] micro services support 5g core network

棋盘左上角到右下角方案数(2)

【DSP】【第二篇】了解C6678和创建工程

Tencent byte Alibaba Xiaomi jd.com offer got a soft hand, and the teacher said it was great

某东短信登录复活 安装部署教程

BUUCTF---Reverse---easyre

Node. Js: express + MySQL realizes registration, login and identity authentication

New generation garbage collector ZGC
随机推荐
设计你的安全架构OKR
BUUCTF---Reverse---easyre
Tencent T3 Daniel will teach you hand-in-hand, the internal information of the factory
Number of schemes from the upper left corner to the lower right corner of the chessboard (2)
B-杰哥的树(状压树形dp)
Boder radius has four values, and boder radius exceeds four values
Redisson bug analysis
Poj3617 best cow line
持续测试(CT)实战经验分享
Tencent Android development interview, basic knowledge of Android Development
Rhcsa Road
What programming do children learn?
Groovy basic syntax collation
Unity makes AB package
How does kubernetes support stateful applications through statefulset? (07)
Catch ball game 1
Learn to punch in Web
Extraction rules and test objectives of performance test points
"Penalty kick" games
Detailed introduction of distributed pressure measurement system VIII: basic introduction of akka actor model