当前位置:网站首页>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里的例程复制 就可以看到实验效果了
边栏推荐
- 记录一下逆向任务管理器的过程
- Descriptor implements ORM model
- Lua uses require to load the shared library successfully, but the return is Boolean (always true)
- 指针笔试题~走近大厂
- Web security SQL injection vulnerability (1)
- Linear regression and logistic regression
- pytorch加载数据
- Remote Sensing Image Super-resolution and Object Detection: Benchmark and State of the Art
- [slam] orb-slam3 parsing - track () (3)
- February 14, 2022 Daily: Google long article summarizes the experience of building four generations of TPU
猜你喜欢
Performance analysis of user login TPS low and CPU full
SAP ALV cell level set color
Problems encountered in 2022 work IV
Linear programming matlab
Tomb. Weekly update of Finance (February 7 - February 13)
指针笔试题~走近大厂
JS音乐在线播放插件vsPlayAudio.js
Precautions for single chip microcomputer anti reverse connection circuit
BUUCTF刷题笔记——[极客大挑战 2019]EasySQL 1
Résumé des méthodes de reconnaissance des caractères ocr
随机推荐
SWC介绍
Item 10: Prefer scoped enums to unscoped enums.
Image super-resolution using deep convolutional networks(SRCNN)解读与实现
NR modulation 1
施努卡:什么是视觉定位系统 视觉系统如何定位
Modeling specifications: naming conventions
【SLAM】ORB-SLAM3解析——跟踪Track()(3)
Analyze menu analysis
[risc-v] external interrupt
Python implementation of maddpg - (1) openai maddpg environment configuration
Shell 传递参数
C language judgment, ternary operation and switch statement usage
1、工程新建
ASU & OSU | model based regularized off-line meta reinforcement learning
数据分析——seaborn可视化(笔记自用)
Distributed service framework dobbo
SD card reports an error "error -110 whilst initializing SD card
2.2 STM32 GPIO操作
指针笔试题~走近大厂
Overview of OCR character recognition methods