当前位置:网站首页>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 点击绘制圆形(动态绘制圆形)
- B-jiege's tree (pressed tree DP)
- 【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
- Color is converted to tristimulus value (r/g/b) (dry stock)
- 【计网】第三章 数据链路层(3)信道划分介质访问控制
- 01 基础入门-概念名词
- Unity load AB package
- Force deduction brush question - 98 Validate binary search tree
- 某东短信登录复活 安装部署教程
- Poj1149 pigs [maximum flow]
猜你喜欢
随机推荐
腾讯字节等大厂面试真题汇总,网易架构师深入讲解Android开发
js获取浏览器系统语言
01 basic introduction - concept nouns
How does kubernetes support stateful applications through statefulset? (07)
Problems encountered in using RT thread component fish
Extraction rules and test objectives of performance test points
Speech recognition (ASR) paper selection: talcs: an open source Mandarin English code switching corps and a speech
[Yann Lecun likes the red stone neural network made by minecraft]
Tencent Android development interview, basic knowledge of Android Development
Unity writes a timer tool to start timing from the whole point. The format is: 00:00:00
New generation garbage collector ZGC
逻辑是个好东西
5. Wireless in vivo nano network: top ten "feasible?" problem
Linear distance between two points of cesium
Unity making plug-ins
String长度限制?
OLED屏幕的使用
B-jiege's tree (pressed tree DP)
小孩子學什麼編程?
Tencent T2 Daniel explained in person and doubled his job hopping salary