##求助 51单片机 keil编译时的一些警告

小白在线求助 2020-12-10 10:30:14
问题:编译后给了四个警告,上网查说是类型不匹配造成的,但是自己定义的这些函数类型都是一样的呀,完全不知道是哪里出了问题

/*这是lcd1602.c模块*/
#include "config.h"
#include "lcd1602.h"

void LCD_Read_busy()
{
uchar busy;
LCD1602_DB = 0xff;
LCD1602_RS = 0;
LCD1602_RW = 1;
do
{
LCD1602_EN = 1;
busy = LCD1602_DB;
LCD1602_EN = 0;
}
while(busy & 0x80);
}
void LCD_Write_cmd(uchar cmd)
{
LCD_Read_busy();

LCD1602_RS = 0;
LCD1602_RW = 0;

LCD1602_DB = cmd;
LCD1602_EN = 1;
LCD1602_EN = 0;
}
void LCD_Write_dat(uchar dat)
{
LCD_Read_busy();
LCD1602_RS = 1;
LCD1602_RW = 0;
LCD1602_DB = dat;
LCD1602_EN = 1;
LCD1602_EN = 0;
}
void Init_LCD1602()
{
LCD_Write_cmd(0x38);
LCD_Write_cmd(0x0f);
LCD_Write_cmd(0x06);
LCD_Write_cmd(0x01);
}
void LCD1602_Set_Cursor(uchar x,uchar y)
{
if(y)
x |= 0x40;

x |= 0x80;
LCD_Write_cmd(x);
}
void LCD_Dis_STR(uchar x,uchar y,uchar *str)
{ //这是keil显示警告的位置 在编译器上这是第66行
LCD1602_Set_Cursor(x,y);
while(*str != '\0')
{
LCD_Write_dat(*str++);
}
}
/*这是主函数模块main.c*/
#define _MAIN_C

#include "config.h"
#include "lcd1602.h"

void main()
{
Init_LCD1602();
LCD_Dis_STR(6,0,"Hello");

while(1);

}

/*这是关于函数声明还有定义声明的config.h*/
#ifndef _CONFIG_H
#define _CONFIG_H


#include <reg52.h>
#include <intrins.h>

#define MAIN_Fosc 11059200UL //宏定义主时钟HZ

//已有数据类型重命名
typedef signed int int16; //16位有符号整型
typedef signed char int8; //8位有符号型

typedef unsigned char uchar8; //8位无符号型
typedef unsigned char uchar; //8位无符号型

typedef unsigned int uint16; //16位无符号型
typedef unsigned int uint; //16位无符号型

typedef unsigned long uint32; //32位无符号型

//硬件接口定义
/*LCD1602液晶引脚*/
#define LCD1602_DB P0
sbit LCD1602_RS = P3^5;
sbit LCD1602_RW = P3^6;
sbit LCD1602_EN = P3^4;

#endif

/*这是lcd1602的一些函数声明*/
#ifndef _LCD1602_H
#define _LCD1602_H

void Init_LCD1602(); //初始化lCD1602
void LCD_Dis_STR(uint x,uint y,uint *str); //lcd1602写字符串
void LCD1602_Set_Cursor(uchar x,uchar y); //LCD1602设置光标显示位置


#endif

...全文
2672 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq1105101451 2020-12-11
  • 打赏
  • 举报
回复
学到了学到了
forget345 2020-12-11
  • 打赏
  • 举报
回复
1、void LCD_Dis_STR(uchar x,uchar y,uchar *str) 的第三个参数 ,改为 char *str ,或 const char *str。
2、LCD_Dis_STR(6,0,"Hello"); 改为 LCD_Dis_STR(6,0,(cahr *)"Hello");
以上你根据时编译信息调整一下
小白在线求助 2020-12-11
  • 打赏
  • 举报
回复
弄好了 是我在.h文件声明的时候写错了类型
forget345 2020-12-11
  • 打赏
  • 举报
回复
头文件
void LCD_Dis_STR(uint x,uint y,uint *str); //lcd1602写字符串 uint *str 也要改啊
小白在线求助 2020-12-11
  • 打赏
  • 举报
回复
不行哎 还是那四个警告 位置也一样

27,375

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 单片机/工控
社区管理员
  • 单片机/工控社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧