当前位置:网站首页>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里的例程复制 就可以看到实验效果了
边栏推荐
- Pytorch load data
- Arabellacpc 2019 (supplementary question)
- Redis cache breakdown, cache penetration, cache avalanche
- [slam] orb-slam3 parsing - track () (3)
- 继承day01
- 遥感图像超分辨重建综述
- 银行核心业务系统性能测试方法
- Huawei, H3C, Cisco command comparison, mind map form from the basic, switching, routing three directions [transferred from wechat official account network technology alliance station]
- SWC介绍
- mysqldump数据备份
猜你喜欢
Record the process of reverse task manager
SWC introduction
Selenium share
暑期刷题-Day3
如何做好功能测试
1.16 - 校验码
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
IPv6 jobs
下一个行业风口:NFT 数字藏品,是机遇还是泡沫?
Derivation of anti Park transform and anti Clarke transform formulas for motor control
随机推荐
Idea push rejected solution
3857墨卡托坐标系转换为4326 (WGS84)经纬度坐标
Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
three.js网页背景动画液态js特效
Add one to non negative integers in the array
Advanced learning of MySQL -- Fundamentals -- isolation level of transactions
resulttype和resultmap的区别和应用场景
jsscript
The next industry outlet: NFT digital collection, is it an opportunity or a foam?
Overview of OCR character recognition methods
SD卡報錯“error -110 whilst initialising SD card
Pytorch基础——(2)张量(tensor)的数学运算
Tidb ecological tools (backup, migration, import / export) collation
Analyze menu analysis
SAP ALV cell level set color
Pytorch load data
多态day02
施努卡:3d视觉检测应用行业 机器视觉3d检测
Web security SQL injection vulnerability (1)
ESBuild & SWC浅谈: 新一代构建工具