Error[Pe167]: argument of type "unsigned char" is incompatible with parameter of

huanglaiming123 2015-05-11 10:49:30
做一个RS232的通信,PC机发送数据给MSP430F149并由12864液晶显示出来,
用IAR for 430 编译程序出现这个错误::Error[Pe167]: argument of type "unsigned char" is incompatible with parameter of type "unsigned char const *" ,
求大神帮忙啊!万分感谢!
程序如下:
/****************POWSOS__430******************************
程序功能:PC通过串口调试精灵向MCU发送数据,MCU将其在1602
液晶上显示
-------------------------------------------------------
通信格式:N.8.1, 9600
------------------------------------------------------
测试说明:打开串口调试助手,正确设置通信格式,向从PC机上
向学习板发送数据,观察液晶上显示的字符。
******************************************************/
#include <msp430.h>
#include "cry12864.h"

typedef unsigned char uchar;
typedef unsigned int uint;

void InitUART(void);
void PutString(uchar *ptr);
/***************主函数************/
void main( void )
{


uchar pX=0,pY=0;
uchar *tishi = "Send data to MCU, and they will be displayed on Cry12864!";

WDTCTL = WDTPW + WDTHOLD; //关狗


InitUART(); //初始化UART
Ini_Lcd(); //初始化LCD

PutString(tishi);
while(1)
{
if(IFG1 & URXIFG0) //如果收到字符
{
Draw_TX(pX++,pY,U0RXBUF);
if(pX == 16)
{
pX = 0;
pY ^= 1;
}
}
}

}
/*******************************************
函数名称:PutSting
功 能:向PC机发送字符串
参 数:ptr--指向发送字符串的指针
返回值 :无
********************************************/
void PutString(uchar *ptr)
{
while(*ptr != '\0')
{
while (!(IFG1 & UTXIFG0)); // TX缓存空闲?
TXBUF0 = *ptr++; // 发送数据
}
while (!(IFG1 & UTXIFG0));
TXBUF0 = '\n';
}
/*******************************************
函数名称:InitUART
功 能:初始化UART端口
参 数:无
返回值 :无
********************************************/
void InitUART(void)
{
P3SEL |= 0x30; // P3.4,5 = USART0 TXD/RXD
ME1 |= URXE0 + UTXE0; // Enable USART0 T/RXD
UCTL0 |= CHAR; // 8-bit character
UTCTL0 |= SSEL0; // UCLK = ACLK
UBR00 = 0x03; // 32k/9600 - 3.41
UBR10 = 0x00; //
UMCTL0 = 0x4A; // Modulation 01001010
UCTL0 &= ~SWRST; // Initialize USART state machine
}
...全文
11462 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2015-05-11
  • 打赏
  • 举报
回复 3
在出错的那个函数参数前加强制类型转换(unsigned char const *)
huanglaiming123 2015-05-11
  • 打赏
  • 举报
回复
这是12864液晶得程序: #include <msp430x14x.h> typedef unsigned char uchar; typedef unsigned int uint; extern const unsigned char shuzi_table[]; #define LCD_DataIn P2DIR=0x00 //数据口方向设置为输入 #define LCD_DataOut P2DIR=0xff //数据口方向设置为输出 #define LCD2MCU_Data P2IN #define MCU2LCD_Data P2OUT #define LCD_CMDOut P6DIR|= BIT3+BIT4+BIT5+BIT6 //P6口的三位设置为输出 #define LCD_RS_H P6OUT|=BIT3 //P6.3 #define LCD_RS_L P6OUT&=~BIT3 //P6.3 #define LCD_RW_H P6OUT|=BIT4 //P6.4 #define LCD_RW_L P6OUT&=~BIT4 //P6.4 #define LCD_EN_H P6OUT|=BIT5 //P6.5 #define LCD_EN_L P6OUT&=~BIT5 //P6.5 /******************************************* 函数名称:Delay_1ms 功 能:延时约1ms的时间 参 数:无 返回值 :无 ********************************************/ void Delay_1ms(void) { uchar i; for(i = 150;i > 0;i--) _NOP(); } /******************************************* 函数名称:Delay_Nms 功 能:延时N个1ms的时间 参 数:n--延时长度 返回值 :无 ********************************************/ void Delay_Nms(uint n) { uint i; for(i = n;i > 0;i--) Delay_1ms(); } /******************************************* 函数名称:Write_Cmd 功 能:向液晶中写控制命令 参 数:cmd--控制命令 返回值 :无 ********************************************/ void Write_Cmd(uchar cmd) { uchar lcdtemp = 0; LCD_RS_L; LCD_RW_H; LCD_DataIn; do //判忙 { LCD_EN_H; _NOP(); lcdtemp = LCD2MCU_Data; LCD_EN_L; } while(lcdtemp & 0x80); LCD_DataOut; LCD_RS_L; LCD_RW_L; MCU2LCD_Data = cmd; LCD_EN_H; _NOP(); LCD_EN_L; } /******************************************* 函数名称:Write_Data 功 能:向液晶中写显示数据 参 数:dat--显示数据 返回值 :无 ********************************************/ void Write_Data(uchar dat) { uchar lcdtemp = 0; LCD_RS_L; LCD_RW_H; LCD_DataIn; do //判忙 { LCD_EN_H; _NOP(); lcdtemp = LCD2MCU_Data; LCD_EN_L; } while(lcdtemp & 0x80); LCD_DataOut; LCD_RS_H; LCD_RW_L; MCU2LCD_Data = dat; LCD_EN_H; _NOP(); LCD_EN_L; } /******************************************* 函数名称:Ini_Lcd 功 能:初始化液晶模块 参 数:无 返回值 :无 ********************************************/ void Ini_Lcd(void) { LCD_CMDOut; //液晶控制端口设置为输出 P6OUT |= BIT6; //并口 // Delay_Nms(500); Write_Cmd(0x30); //基本指令集 Delay_1ms(); Write_Cmd(0x02); // 地址归位 Delay_1ms(); Write_Cmd(0x0c); //整体显示打开,游标关闭 Delay_1ms(); Write_Cmd(0x01); //清除显示 Delay_1ms(); Write_Cmd(0x06); //游标右移 Delay_1ms(); Write_Cmd(0x80); //设定显示的起始地址 } /******************************************* 函数名称:Clear_GDRAM 功 能:清除液晶GDRAM中的随机数据 参 数:无 返回值 :无 ********************************************/ void Clear_GDRAM(void) { uchar i,j,k; Write_Cmd(0x34); //打开扩展指令集 i = 0x80; for(j = 0;j < 32;j++) { Write_Cmd(i++); Write_Cmd(0x80); for(k = 0;k < 16;k++) { Write_Data(0x00); } } i = 0x80; for(j = 0;j < 32;j++) { Write_Cmd(i++); Write_Cmd(0x88); for(k = 0;k < 16;k++) { Write_Data(0x00); } } Write_Cmd(0x30); //回到基本指令集 } /******************************************* 函数名称:Draw_TX 功 能:显示一个16*16大小的图形 参 数:Yaddr--Y地址 Xaddr--X地址 dp--指向图形数据存放地址的指针 返回值 :无 ********************************************/ void Draw_TX(uchar Yaddr,uchar Xaddr,const uchar * dp) { uchar j; uchar k=0; // Write_Cmd(0x01); //清屏,只能清除DDRAM Write_Cmd(0x34); //使用扩展指令集,关闭绘图显示 for(j=0;j<16;j++) { Write_Cmd(Yaddr++); //Y地址 Write_Cmd(Xaddr); //X地址 Write_Data(dp[k++]); Write_Data(dp[k++]); } Write_Cmd(0x36); //打开绘图显示 // Write_Cmd(0x30); //回到基本指令集模式 }

69,382

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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