当前位置:网站首页>Cubemx 移植正点原子LCD显示例程
Cubemx 移植正点原子LCD显示例程
2022-07-06 03:20:00 【2020级机器人实验班】
不讲原理,只移植。
打开cubemx,选择芯片的过程不说。
选择时钟:
下载方式:
串口1,因为板子上有ch340,可以直接通过数据线发送到电脑。没有ch340的板子可以选择使用TTL转串口。
点击FSMC 再点击第一个。
按照如下方式进行选择,需要看开发板原理图。
将extended mode 使能
打开正点原子官方例程:
如果是在跳转到定义的时候报了这个错误。
点开魔术棒,将output中的Browse Information 勾选上再进行编译。
找到 LCD_Init
对照结构体里的各个参数,得出以下设置
将背光引脚选择成输出模式。
将时钟修改成72M
在正点原子例程中找到这三个文件,分别复制到以下Inc和Src中。
编译一下我们会看到很多的错误
很多错误,我们一个个来。
将include "delay.h"删除,再在main.h中添加如下
typedef uint32_t u32;
typedef uint16_t u16;
typedef uint8_t u8;
typedef __IO uint32_t vu32;
typedef __IO uint16_t vu16;
typedef __IO uint8_t vu8;
再将lcd.h中的sys改成main,将main的头文件添加进来
然后错误明显减少
存在微秒级别的延时,但是HAL库没有这个函数,所以我们统一换成 延时一毫秒,毫秒级的延时泽替换成HAL库的毫秒延时就行。
HAL_Delay(1);
修改完成后
因为LCD_Init函数要使用printf,所以需要添加头文件
#include "stdio.h"
将LCD_LED =1 修改成以下句子
HAL_GPIO_WritePin(LCD_BL_GPIO_Port,LCD_BL_Pin,GPIO_PIN_SET);
将 LCD_Init 函数中 HAL_Delay(50) 之前的代码全部删除。
将 HAL_SRAM_MspInit 函数删除
在主函数添加以下头文件。
#include "lcd.h"
#include "stdio.h"
再在usart.c的最下方添加串口重定向就完成了。
#include<stdio.h>
#ifdef __GNUC__
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#else
#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
#endif
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
将正点原子main里的例程复制 就可以看到实验效果了
边栏推荐
- 出现Permission denied的解决办法(750权限谨慎使用)
- Esbuild & SWC: a new generation of construction tools
- 下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
- Safety science to | travel, you must read a guide
- JS音乐在线播放插件vsPlayAudio.js
- SWC介绍
- Four logs of MySQL server layer
- Huawei, H3C, Cisco command comparison, mind map form from the basic, switching, routing three directions [transferred from wechat official account network technology alliance station]
- [Li Kou] the second set of the 280 Li Kou weekly match
- 2.1 rtthread pin设备详解
猜你喜欢
OCR文字识别方法综述
Performance test method of bank core business system
Mysql database operation
The real machine cannot access the shooting range of the virtual machine, and the real machine cannot Ping the virtual machine
指针笔试题~走近大厂
EDCircles: A real-time circle detector with a false detection control 翻译
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
Safety science to | travel, you must read a guide
Python implementation of maddpg - (1) openai maddpg environment configuration
MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
随机推荐
BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1
Python implementation of maddpg - (1) openai maddpg environment configuration
Redo file corruption repair
11. Container with the most water
JS regular filtering and adding image prefixes in rich text
数据分析——seaborn可视化(笔记自用)
2022工作中遇到的问题四
Buuctf question brushing notes - [geek challenge 2019] easysql 1
Esbuild & SWC: a new generation of construction tools
深入刨析的指针(题解)
My C language learning record (blue bridge) -- under the pointer
【paddle】加载模型权重后预测报错AttributeError: ‘Model‘ object has no attribute ‘_place‘
[padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
遥感图像超分辨率论文推荐
这些不太会
【Rust 笔记】18-宏
下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
The solution of permission denied (750 permissions should be used with caution)
Modeling specifications: naming conventions
Linear regression and logistic regression