launchPad 串行显示图片的问题

2019-03-24 13:48发布

最近玩12864串行程序,在做图片时,将并行口程序的图片数组复制过来,出现了如图的错误,认为串口和并口不一样的传输方式,在显示图片是有什么不同...求大神发一个串行图片的程序。。 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
4条回答
tanzhen807
2019-03-25 00:11
< :TI_MSP430_内容页_SA7 --> #include <MSP430g2231.h>

unsigned char  LCDsheji[1024]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x40,0x00,
0x00,0x0C,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,
0x00,0x36,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x6C,0x00,
0x00,0xF7,0x80,0x00,0x00,0x00,0xE0,0x07,0xC1,0xFC,0x00,0x00,0x00,0x01,0xEF,0x00,
0x00,0xF0,0x00,0x00,0x00,0x00,0xE0,0x1F,0xE1,0xFF,0x00,0x00,0x00,0x00,0x0F,0x00,
0x00,0xC1,0xE0,0x00,0x00,0x00,0xE0,0x1F,0xE1,0xFF,0x00,0x00,0x00,0x07,0x83,0x00,
0x00,0xB0,0x18,0x00,0x00,0x00,0xE0,0x3C,0xF1,0xC7,0x80,0x00,0x00,0x18,0x0D,0x00,
0x00,0xE0,0x7C,0x00,0x00,0x00,0xE0,0x38,0x71,0xC3,0x80,0x00,0x00,0x3E,0x07,0x00,
0x00,0xFC,0x57,0xC0,0x00,0x00,0xE0,0x38,0x71,0xC3,0x80,0x00,0x03,0xEA,0x3F,0x00,
0x01,0x22,0x7D,0xC0,0x00,0x00,0xE0,0x38,0x01,0xC3,0x80,0x00,0x03,0xBE,0x44,0x80,
0x01,0x4A,0xCC,0xC0,0x00,0x00,0xE0,0x38,0x01,0xC3,0x80,0x00,0x03,0x33,0x52,0x80,
0x0D,0x5B,0x5E,0xC0,0x00,0x00,0xE0,0x38,0x01,0xC3,0x80,0x00,0x03,0x7A,0xDA,0xB0,
0x0F,0xA2,0xFB,0xC0,0x00,0x00,0xE0,0x38,0x01,0xC3,0x80,0x00,0x03,0xDF,0x45,0xF0,
0x1F,0x9C,0xA2,0x40,0x00,0x00,0xE0,0x38,0x71,0xC3,0x80,0x00,0x02,0x45,0x39,0xF8,
0x19,0xE0,0x06,0x40,0x00,0x00,0xE0,0x38,0x71,0xC3,0x80,0x00,0x02,0x60,0x07,0x98,
0x0F,0xB0,0x0E,0x40,0x00,0x00,0xE0,0x3C,0x71,0xC7,0x80,0x00,0x02,0x70,0x0D,0xF0,
0x0D,0x0C,0x7E,0x40,0x03,0x80,0xFF,0x1F,0xF1,0xFF,0x01,0xC0,0x02,0x7E,0x30,0xB0,
0x03,0x03,0xAE,0xC0,0x17,0x80,0xFF,0x1F,0xE1,0xFF,0x01,0xE8,0x03,0x75,0xC0,0xC0,
0x00,0x81,0xFE,0x80,0x13,0xC0,0xFF,0x07,0xC1,0xFC,0x03,0xC8,0x01,0x7F,0x81,0x00,
0x00,0xC0,0xFF,0x80,0x15,0xE0,0x00,0x00,0x00,0x00,0x07,0xA8,0x01,0xFF,0x03,0x00,
0x00,0x60,0x7F,0x00,0x1F,0x20,0x00,0x00,0x00,0x00,0x04,0xF8,0x00,0xFE,0x06,0x00,
0x00,0x18,0x1E,0x00,0x0D,0x10,0x00,0x00,0x00,0x00,0x08,0xB0,0x00,0x78,0x18,0x00,
0x00,0x07,0xF2,0x00,0x09,0xD0,0x00,0x00,0x00,0x00,0x0B,0x90,0x00,0x4F,0xE0,0x00,
0x00,0x08,0x23,0xE0,0x73,0x30,0x00,0x60,0x00,0x00,0x0C,0xCE,0x07,0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0x33,0x8F,0x0F,0xF9,0x01,0xFF,0xFE,0x04,0xD0,
0x08,0x10,0x1F,0xF0,0x03,0xBD,0xE0,0x0E,0x06,0x07,0xBD,0xC0,0x0F,0xF8,0x08,0x10,
0x0A,0x50,0x0F,0xF0,0xFF,0xBD,0xE0,0x00,0x00,0x07,0xBD,0xFF,0x0F,0xF0,0x0A,0x50,
0x0E,0xD0,0x0F,0xF7,0x10,0xFD,0xE0,0x00,0x00,0x07,0xBF,0x08,0xEF,0xF0,0x0B,0x70,
0x03,0xA0,0x0B,0xE8,0x0C,0xBF,0xE0,0x00,0x00,0x07,0xFD,0x30,0x17,0xD0,0x05,0xC0,
0x01,0xC0,0x09,0xE0,0x04,0xCF,0xE0,0x00,0x00,0x07,0xF3,0x20,0x07,0x90,0x03,0x80,
0x00,0x00,0x08,0xC0,0x7F,0xFF,0xE0,0x60,0x30,0x07,0xFF,0xFE,0x03,0x10,0x00,0x00,
0x1C,0x00,0x0C,0x07,0x81,0x17,0xE0,0x30,0x30,0x07,0xE8,0x81,0xE0,0x30,0x00,0x38,
0x1F,0x3F,0x1F,0xFC,0x00,0x07,0xC0,0x38,0x30,0x03,0xE0,0x00,0x3F,0xF8,0xFC,0xF8,
0x1F,0x81,0xB3,0xEC,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x37,0xCD,0x81,0xF8,
0x3E,0x21,0xE2,0x08,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x10,0x47,0x84,0x7C,
0x3E,0x03,0x04,0x18,0x00,0x00,0x00,0xFB,0xFF,0x00,0x00,0x00,0x18,0x20,0xC0,0x7C,
0x2F,0x42,0x1C,0x10,0x00,0x00,0x00,0x18,0x30,0x00,0x00,0x00,0x08,0x38,0x42,0xF4,
0x2F,0xC3,0x78,0x30,0x00,0x00,0x00,0x18,0x30,0x00,0x00,0x00,0x0C,0x1E,0xC3,0xF4,
0x2F,0xC2,0xD8,0x60,0x00,0x00,0x00,0x18,0x30,0x00,0x00,0x00,0x06,0x1B,0x43,0xF4,
0x2F,0xC2,0x00,0xC0,0x00,0x00,0x00,0x18,0x30,0x00,0x00,0x00,0x03,0x00,0x43,0xF4,
0x2F,0xC2,0x00,0x80,0x00,0x00,0x00,0x18,0x30,0x00,0x00,0x00,0x01,0x00,0x43,0xF4,
0x2F,0xC3,0xC3,0x80,0x00,0x00,0x00,0x1B,0x30,0x00,0x00,0x00,0x01,0xC3,0xC3,0xF4,
0x0F,0xBF,0x3E,0x00,0x00,0x00,0x00,0x1E,0x30,0x00,0x00,0x00,0x00,0x7C,0xFD,0xF0,
0x1F,0xC0,0x00,0x00,0x00,0x00,0x00,0x1C,0x30,0x00,0x00,0x00,0x00,0x00,0x03,0xF8,
0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x18,0x30,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,
0x0F,0xA0,0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x00,0x00,0x00,0x00,0x05,0xF0,
0x0F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

void int_port(void)                    //管脚初始化
{
  P1SEL&=~BIT4;                        //P1.4模拟SID,设置为i/o口输出方向
  P1DIR|=BIT4;
  P1OUT&=~BIT4;
  P1SEL&=~BIT5;                        //P1.5模拟SCLK,设置为i/o口输出方向
  P1DIR|=BIT5;
  P1OUT&=~BIT5;
}
void delay(unsigned int t)             //延时函数
{                                      //粗略延时,满足时序要求
unsigned int i,j;
for(i=0; i<t;  i++)
        for(j=0; j<10; j++);
}
void sendbyte(unsigned char zdata)     //数据传送函数
{
  unsigned char code_seg7;
  unsigned char serial_clk;
  unsigned char serial_shift;
  code_seg7=zdata;
  serial_shift=0x80;
  for(serial_clk=0; serial_clk<8; serial_clk++)
  {
    if(code_seg7&serial_shift)
    {
      P1OUT|=BIT4;                     //SID为1
    }
    else
    {
      P1OUT&=~BIT4;                    //SID为0
    }
    P1OUT&=~BIT5;                      //产生时钟信号下沿
    P1OUT|=BIT5;                       //产生时钟信号上沿
    serial_shift=serial_shift>>1;      //准备发送下一位数据
  }
}
void write_com(unsigned char cmdcode)  //写命令函数
{                                      //串口控制格式(11111AB0)
                                //A数据方向控制,A=H时读,A=L时写
                                       //B数据类型选择,B=H时为显示数据,B=L时为命令
sendbyte(0xf8);                //MCU向LCD发命令

        sendbyte(cmdcode & 0xf0);      //发高四位数据(数据格式D7D6D5D4_0000)
sendbyte((cmdcode << 4) & 0xf0);//发低四位数据(数据格式D3D2D1D0_0000)
delay(2);                      //延时等待
}
void write_data(unsigned char Dispdata)//写数据函数
{

sendbyte(0xfa);                //MCU向LCD发数据
sendbyte(Dispdata & 0xf0);     //发高四位数据
sendbyte((Dispdata << 4) & 0xf0);//发低四位数据
delay(2);
}
void lcdinit()                         //LCD初始化
{
delay(20000);                  //复位等待(内部自带上电复位电路),时间较长
write_com(0x30);               //功能设定:基本指令集操作
delay(50);                     //延时等待
write_com(0x0c);               //整体显示,关游标
delay(50);
}
void print_string(unsigned char *s)          //发送字符串
{
while(*s > 0)                  //C语言里字符串末尾自动加“”(ASCII码值为0)
    {
  write_data(*s);        //发送字符对应的ASCII码,12864指针可设置自动指向下一个显示地址
  s++;
  delay(50);
    }
}

void pic_Disp(unsigned char *pic)    //显示Gdram内容(显示图片)
{
unsigned char x,y,i;
for(i=0;i<9;i=i+8)
for(y=0;y<32;y++)
{
  for(x=0;x<8;x++)
  {
          write_com(0x36);   //扩充指令,开绘图显示
          write_com(0x80+y);  //行地址
          write_com(0x80+x+i);  //列地址
          write_data(*pic++);  //写数据 D15-D8
          write_data(*pic++);  //写数据 D7-D0
          write_data(0x30);
  }
}
}
void Test()
{       unsigned char dat1,dat2,dat3,dat4;
dat1=1;dat2=2;dat3=3;dat4=4;
        write_com(0x03);              //发指令,地址归位
delay(50);                     //延时
write_com(0x80);               //第一行首地址0x80
print_string("德州仪器MSP430 "); //第一行显示(必须加一个空格否则不能下载)
              //较长时间延时,保证下次操作前LCD完成上述功能处于非忙状态
}
void main()
{
        WDTCTL=WDTPW+WDTHOLD;          //关闭看门狗
        int_port();                    //端口初始化
lcdinit();                     //LCD初始化
pic_Disp(LCDsheji);
//Test();                        //测试
while(1);                      //CPU空转
}

程序贴了出来,图片数组时并行移植过来的。改了半天没改好》。

一周热门 更多>

相关问题

    相关文章