找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 2104|回復(fù): 0
打印 上一主題 下一主題
收起左側(cè)

C語言在Dis_str(i,0,*p)處報(bào)錯(cuò)指針轉(zhuǎn)換錯(cuò)誤 怎么改

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:377512 發(fā)表于 2018-12-17 20:21 | 只看該作者 回帖獎(jiǎng)勵(lì) |倒序?yàn)g覽 |閱讀模式
#include <reg52.h>
#include<intrins.h>

typedef unsigned char uchar;
typedef unsigned int uint;

sbit RS = P3^5;
sbit RW = P3^6;
sbit EN = P3^4;

#define LCD1602_A P0

void delay_ms(uint n)
{
uint i,y;
for(i=n;i>0;i--)
        {
  for(y=114;y>0;y--);
        }               
}


void Read_busy()
{
   uchar busy;
         LCD1602_A = 0xff;
         RS = 0;
         RW = 1;
        do{
           EN = 1;
                 busy = LCD1602_A;
                 EN = 0;
        }while(busy & 0x80);
}


void Write_cmd(uchar cmd)
  {
    Read_busy();
          RS = 0;
                RW = 0;
                LCD1602_A = cmd;
                EN = 1;
                EN = 0;
}


void Write_dat(uchar dat)
{
  Read_busy();
        RS = 1;
        RW = 0;
        LCD1602_A = dat;
        EN = 1;
        EN = 0;
}


void Dis_onechar(uchar x, uchar y, uchar dat)
{
   if(y) x |= 0x40;
           x |= 0x80;
        Write_cmd(x);
        Write_dat(dat);
}


void Dis_str(uchar x, uchar y, uchar *str)
{
   if(y) x |= 0x40;
            x |= 0x80;
         Write_cmd(x);
         while(*str != '\0')
         {
            Write_dat(*str++);
         }
}

void Init_LCD1602()
{
   Write_cmd(0x38);
         Write_cmd(0x0c);
         Write_cmd(0x06);
         Write_cmd(0x01);
}
void main()
{
        while(1)
        {
        uchar i = 1;
        uchar str[20]={"Just do it ! "} ;
        uchar *p;
        p = str;
        Init_LCD1602();
        while(1)
{
  Dis_str(i,0,*p);
        i++;
        P++;
        delay_ms(1000);
        }
        delay_ms(1000);
  }
}

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

手機(jī)版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表