当前位置:网站首页>OLED屏幕的使用
OLED屏幕的使用
2022-07-06 12:24: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
边栏推荐
猜你喜欢
Anaconda安裝後Jupyter launch 沒反應&網頁打開運行沒執行
Tencent T4 architect, Android interview Foundation
Leetcode question 283 Move zero
【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
新一代垃圾回收器—ZGC
Introduction of Xia Zhigang
RT thread I2C tutorial
Crawler (14) - scrape redis distributed crawler (1) | detailed explanation
Basic knowledge of lists
Jupyter launch didn't respond after Anaconda was installed & the web page was opened and ran without execution
随机推荐
Leetcode question 448 Find all missing numbers in the array
为什么新手在编程社区提问经常得不到回答,甚至还会被嘲讽?
01 基础入门-概念名词
夏志刚介绍
Event center parameter transfer, peer component value transfer method, brother component value transfer
Tencent architects first, 2022 Android interview written examination summary
枚举根据参数获取值
[network planning] Chapter 3 data link layer (3) channel division medium access control
Digital triangle model acwing 1018 Minimum toll
Special topic of rotor position estimation of permanent magnet synchronous motor -- Summary of position estimation of fundamental wave model
RT-Thread 组件 FinSH 使用时遇到的问题
Logstash expressway entrance
Poj3617 best cow line
rt-thread i2c 使用教程
Period compression filter
RT thread I2C tutorial
系统与应用监控的思路和方法
8086指令码汇总表(表格)
Appx code signing Guide
Boder radius has four values, and boder radius exceeds four values