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

边栏推荐
- Performance test method of bank core business system
- SAP ALV单元格级别设置颜色
- 如何做好功能测试
- [padding] an error is reported in the prediction after loading the model weight attributeerror: 'model' object has no attribute '_ place‘
- 蓝色样式商城网站页脚代码
- 【SLAM】ORB-SLAM3解析——跟踪Track()(3)
- ESBuild & SWC浅谈: 新一代构建工具
- SWC introduction
- [rust notes] 18 macro
- 2、GPIO相关操作
猜你喜欢

Performance test method of bank core business system

Four logs of MySQL server layer
![BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1](/img/37/c38a933ce7fa5d2b8fa597965ffcb2.png)
BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1

真机无法访问虚拟机的靶场,真机无法ping通虚拟机

Pytorch load data

【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板

教你用Pytorch搭建一个自己的简单的BP神经网络( 以iris数据集为例 )

Record the process of reverse task manager

The real machine cannot access the shooting range of the virtual machine, and the real machine cannot Ping the virtual machine

Safety science to | travel, you must read a guide
随机推荐
1003 emergency (25 points), "DIJ deformation"
Leetcode problem solving -- 99 Restore binary search tree
[risc-v] external interrupt
Redis SDS principle
My C language learning record (blue bridge) -- under the pointer
Résumé des méthodes de reconnaissance des caractères ocr
1.16 - 校验码
Princeton University, Peking University & UIUC | offline reinforcement learning with realizability and single strategy concentration
MySQL Server层四个日志
Python implementation of maddpg - (1) openai maddpg environment configuration
【paddle】加载模型权重后预测报错AttributeError: ‘Model‘ object has no attribute ‘_place‘
These are not very good
Audio-AudioRecord Binder通信机制
XSS challenges bypass the protection strategy for XSS injection
Force buckle 1189 Maximum number of "balloons"
【SLAM】lidar-camera外参标定(港大MarsLab)无需二维码标定板
Shell pass parameters
NR modulation 1
Map sorts according to the key value (ascending plus descending)
NR modulation 1