当前位置:网站首页>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里的例程复制 就可以看到实验效果了

边栏推荐
- Exness foreign exchange: the governor of the Bank of Canada said that the interest rate hike would be more moderate, and the United States and Canada fell slightly to maintain range volatility
- Descriptor implements ORM model
- Crazy, thousands of netizens are exploding the company's salary
- 如何做好功能测试
- Tomb. Weekly update of Finance (February 7 - February 13)
- Teach you to build your own simple BP neural network with pytoch (take iris data set as an example)
- XSS challenges bypass the protection strategy for XSS injection
- ASU & OSU | model based regularized off-line meta reinforcement learning
- MADDPG的pythorch实现——(1)OpenAI MADDPG环境配置
- svg拖动点裁剪图片js特效
猜你喜欢

NR modulation 1

Esbuild & SWC: a new generation of construction tools

Derivation of anti Park transform and anti Clarke transform formulas for motor control

svg拖动点裁剪图片js特效

Problems encountered in 2022 work IV

I sorted out a classic interview question for my job hopping friends

OCR文字識別方法綜述
![Buuctf question brushing notes - [geek challenge 2019] easysql 1](/img/37/c38a933ce7fa5d2b8fa597965ffcb2.png)
Buuctf question brushing notes - [geek challenge 2019] easysql 1

SAP ALV单元格级别设置颜色

Brush questions in summer -day3
随机推荐
Linear programming matlab
Huawei, H3C, Cisco command comparison, mind map form from the basic, switching, routing three directions [transferred from wechat official account network technology alliance station]
StrError & PERROR use yyds dry inventory
Audio-AudioRecord Binder通信机制
Jenkins basic knowledge ----- detailed explanation of 03pipeline code
three.js网页背景动画液态js特效
Force buckle 1189 Maximum number of "balloons"
resulttype和resultmap的区别和应用场景
1.16 - 校验码
真机无法访问虚拟机的靶场,真机无法ping通虚拟机
如何做好功能测试
February 14, 2022 Daily: Google long article summarizes the experience of building four generations of TPU
Codeworks 5 questions per day (1700 average) - day 6
3.1 rtthread 串口设备(V1)详解
Pytorch基础——(1)张量(tensor)的初始化
适合程序员学习的国外网站推荐
Four logs of MySQL server layer
Eight super classic pointer interview questions (3000 words in detail)
Brush questions in summer -day3
2.2 STM32 GPIO操作