当前位置:网站首页>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
边栏推荐
- 小孩子学什么编程?
- Force deduction brush question - 98 Validate binary search tree
- 【每周一坑】计算100以内质数之和 +【解答】输出三角形
- 设计你的安全架构OKR
- Basic knowledge of lists
- Qinglong panel white screen one key repair
- Database specific interpretation of paradigm
- [Yann Lecun likes the red stone neural network made by minecraft]
- A5000 vgpu display mode switching
- HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
猜你喜欢

【每周一坑】计算100以内质数之和 +【解答】输出三角形

02 基础入门-数据包拓展

Event center parameter transfer, peer component value transfer method, brother component value transfer

Tencent T3 teaches you hand in hand. It's really delicious

Jupyter launch didn't respond after Anaconda was installed & the web page was opened and ran without execution

电子游戏的核心原理

设计你的安全架构OKR

Maximum likelihood estimation and cross entropy loss

案例 ①|主机安全建设:3个层级,11大能力的最佳实践

PowerPivot - DAX (first time)
随机推荐
OceanBase社区版之OBD方式部署方式单机安装
8086指令码汇总表(表格)
B-jiege's tree (pressed tree DP)
Linear distance between two points of cesium
Quel genre de programmation les enfants apprennent - ils?
Oceanbase Community Edition OBD mode deployment mode stand-alone installation
Cesium 两点之间的直线距离
Unity making plug-ins
Poj3617 best cow line
JS get browser system language
Appx code signing Guide
【DSP】【第二篇】了解C6678和创建工程
Cesium Click to draw a circle (dynamically draw a circle)
Event center parameter transfer, peer component value transfer method, brother component value transfer
"Penalty kick" games
看过很多教程,却依然写不好一个程序,怎么破?
Le lancement du jupyter ne répond pas après l'installation d'Anaconda
RT-Thread 组件 FinSH 使用时遇到的问题
Web开发小妙招:巧用ThreadLocal规避层层传值
Tencent T3 teaches you hand in hand. It's really delicious