用74164写了个串口转并口的lcd显示程序 编译有2个警告 显示不了
警告为
Executing: "C:Program FilesHI-TECH SoftwarePICC9.80inpicc.exe" --pass1 "D:pic cccpppt.c" -q --chip=16F883 -P --runtime=default --opt=default -D__DEBUG=1 -g --asmlist "--errformat=Error [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s"
Warning [359] D:pic cccpppt.c; 141.27 illegal conversion between pointer types
pointer to const unsigned char -> pointer to unsigned char
Warning [359] D:pic cccpppt.c; 145.28 illegal conversion between pointer types
pointer to const unsigned char -> pointer to unsigned char
此警告是关于void LCD_write_str(uchar x,uchar y, uchar *s)函数的 看了半天找不出错误来 各位帮忙看看
片子是pic16f883
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
-----------------------------------------------------------------------
没给程序,没办法帮你测试。
#include <pic.h>
__CONFIG(0xe0f1);
#define uint unsigned int
#define uchar unsigned char
#define _nop_() asm("nop")
#define SCK RC6
#define DATA RC7
#define RS RA3
#define RW RA4
#define EN RA5
const uchar Bit[8]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80};
void LCD_CK(void);
void Process_Data(uchar data);
void LCD_write_com(uchar com);
void LCD_write_data(uchar data);
void LCD_clear(void);
void LCD_write_str(uchar x,uchar y,uchar *s);
void LCD_write_char(uchar x,uchar y,uchar data);
void LCD_init(void);
void delayms(char ms_delay) //4M晶振1ms延时
{
unsigned int count=100*ms_delay;
while(--count)
{;}
}
void delayus(char us_delay)
{
unsigned int i;
for(i=0;i<us_delay;i++)
{ _nop_(); }
}
void LCD_CK(void)
{
SCK=0;
_nop_();
SCK=1;
//_nop_();
//SCK=0;
}
void Process_Data(uchar data)
{
uchar k;
for(k=8;k>0;k--)
{
if(data&Bit[k-1])
{
DATA=1;
LCD_CK();
}
else
{
DATA=0;
LCD_CK();
}
}
}
void LCD_write_com(uchar com)
{
RS=0;
RW=0;
EN=1;
Process_Data(com);
delayus(5);
EN=0;
}
void LCD_write_data(uchar data)
{
RS=1;
RW=0;
EN=1;
Process_Data(data);
delayus(5);
EN=0;
}
void LCD_clear(void)
{
LCD_write_com(0x01);
delayms(5);
}
void LCD_set_xy(uchar x,uchar y)
{
uchar address;
if(y==1)
address=0x80+x;
else
address=0xc0+x;
LCD_write_com(address);
}
void LCD_write_str(uchar x,uchar y, uchar *str)
{
LCD_set_xy(x,y);
while (*str)
{
LCD_write_data( *str);
str ++;
}
}
void LCD_write_char(uchar x,uchar y,uchar data)
{
LCD_set_xy(x,y);
LCD_write_data( data);
}
void LCD_init(void)
{
LCD_write_com(0x38);
delayms(5);
LCD_write_com(0x38);
delayms(5);
LCD_write_com(0x38);
delayms(5);
LCD_write_com(0x38);
LCD_write_com(0x08);
LCD_write_com(0x01);
LCD_write_com(0x06);
delayms(5);
LCD_write_com(0x0C);
}
void init(void)
{
TRISA=0b00000000;
TRISC=0b00000000;
PORTA=0;
PORTC=0xc0;
ANSEL=0x00;
}
void main()
{
init();
LCD_init();
LCD_write_str(0,1,"456");
LCD_write_str(0,2,"3124");
delayms(500);
}
{
LCD_set_xy(x,y);
while (*str)
{
LCD_write_data( *str);
str ++;
}
}
一周热门 更多>