【课后练习】LaunchPad课后练习六之LCD12864显示图片

常见泽1   2012-5-30 11:29 楼主

 

1. 原理图

1.jpg

 

2.  取模过程

1.jpg

2.jpg

当然你也可以不保存单色位图,把图片导入word,选择黑白,如下:

3.jpg

 

4.jpg

打开制作好的图片:

 

6.jpg

 

取模方式

7.jpg

8.jpg

 

5.jpg

 

3. 实验现象

20120530104513.jpg

 

课后练习六之LCD12864显示图片.pdf (769.96 KB)
(下载次数: 514, 2012-5-30 11:29 上传)

 

 

 

 

 

回复评论 (16)


  1. /***********************************************
    **** LAUNCH PAD 学习之LCD ***
    **** MCU: MSP430 ***
    **** 作者: 常见泽 ***
    **** ***
    **** ***
    **** 2012.05.30.11:16 ***
    **** 实验现象:LCD显示EE LOG ***
    **** ***
    ****P1.0~P1.7 数据口 P2.0 P2.1 P2.2 en rs Psb***
    ***********************************************/
    #include <msp430g2452.h>
    #define uchar unsigned char
    #define uint unsigned int

    unsigned char table[]="EE-LaunchPad";
    unsigned char num;
    void delay_1ms(void)
    {
    unsigned int i;
    for (i=0;i<1140;i++);
    }

    const unsigned char ucpic[]=
    {
    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,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,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,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,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,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,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,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x0F,0xFF,0xFF,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x1F,0xFF,0xFF,0xFC,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x3F,0xFF,0xC3,0xFC,0x00,0x30,0x00,0x06,0x00,0xE0,0x06,0x66,0x19,0x8C,0x31,
    0x00,0x3F,0xFF,0xC3,0xFC,0x00,0x30,0x00,0x06,0x00,0xE0,0x06,0x66,0x19,0x8C,0x31,
    0x00,0x3F,0xFE,0x01,0xFE,0x02,0x39,0x00,0x06,0x00,0xC0,0x0C,0x62,0x19,0x8C,0x31,
    0x00,0x3F,0xF8,0x00,0xFE,0x07,0x31,0x80,0xFC,0x00,0xC0,0x0C,0x62,0x19,0x8C,0x31,
    0x00,0x3F,0xF0,0x00,0xFE,0x06,0x31,0x80,0x78,0x00,0xC0,0x0C,0x66,0x1D,0xDC,0x31,
    0x00,0x3F,0xE0,0x01,0xFE,0x06,0x31,0x80,0x30,0x00,0xC0,0x0C,0x00,0x19,0xCC,0x30,
    0x00,0x3F,0xC0,0x03,0xFE,0x07,0x39,0x80,0x38,0x00,0xC0,0x1F,0x00,0x18,0x8C,0x00,
    0x00,0x3F,0xC0,0x03,0xFE,0x07,0x39,0x80,0x38,0x00,0xC0,0x1F,0x00,0x18,0x8C,0x00,
    0x00,0x3F,0xC0,0x3F,0xFE,0x06,0x31,0x80,0x38,0x00,0xC0,0x3D,0x18,0x19,0x8C,0x0C,
    0x00,0x3F,0x80,0x7F,0xFE,0x06,0x31,0x80,0x38,0x00,0xE0,0x3D,0x18,0x19,0x8C,0x1C,
    0x00,0x3F,0x80,0xFF,0xFE,0x06,0x31,0x80,0x18,0x00,0xE0,0x3D,0x18,0x19,0x8C,0x3C,
    0x00,0x3F,0x81,0xF3,0xFE,0x07,0x31,0x80,0x38,0x00,0xE0,0x3F,0x18,0x19,0xD8,0x0C,
    0x00,0x3F,0x81,0xF3,0xFE,0x07,0x31,0x80,0x38,0x00,0xE0,0x3F,0x18,0x19,0xD8,0x0C,
    0x00,0x3F,0x03,0xC1,0xFE,0x00,0x30,0x00,0x30,0x00,0xE0,0x3F,0x18,0x18,0x00,0x0C,
    0x00,0x3F,0x03,0xC0,0xFE,0x00,0x30,0x01,0xF0,0x00,0xE0,0x35,0x18,0x1C,0x00,0x0C,
    0x00,0x3F,0x03,0x80,0xFE,0x00,0x3C,0x80,0x00,0x00,0xE0,0x0C,0x18,0x0C,0x00,0x18,
    0x00,0x3F,0x03,0x80,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x3F,0x03,0x80,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x3F,0x03,0xC0,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x3F,0x01,0xC1,0xFE,0x1F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
    0x00,0x3F,0x81,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x3F,0x80,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x3F,0x80,0xFF,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00,0x3F,0x80,0x7F,0xFE,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x00,0x00,0x00,0x00,
    0x00,0x3F,0xC0,0x0F,0xFE,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,
    0x00,0x3F,0xE0,0x01,0xFE,0x01,0x01,0x80,0x00,0x60,0x10,0xD0,0x00,0x00,0x00,0x00,
    0x00,0x3F,0xF0,0x01,0xFE,0x04,0x44,0x4C,0x89,0xB1,0x93,0x70,0x00,0x00,0x00,0x00,
    0x00,0x3F,0xF8,0x00,0xFE,0x0C,0x4C,0x4D,0xD3,0x1B,0x12,0x30,0x78,0xE3,0xF8,0x3C,
    0x00,0x3F,0xF8,0x00,0xFE,0x0C,0x4C,0x4D,0xD3,0x1B,0x12,0x30,0x78,0xE3,0xF8,0x3C,
    0x00,0x3F,0xFC,0x01,0xFE,0x0F,0xCF,0xC5,0xF2,0x12,0x24,0x30,0x81,0x16,0x48,0x60,
    0x00,0x3F,0xFF,0x01,0xFE,0x08,0x08,0x06,0x62,0x12,0x24,0x20,0x82,0x14,0x88,0x40,
    0x00,0x3F,0xFF,0xFF,0xFE,0x08,0x08,0x06,0x63,0x26,0x26,0x60,0x83,0x24,0x88,0x40,
    0x00,0x0F,0xFF,0xFF,0xFE,0x07,0x07,0x04,0x41,0xC4,0x63,0xE4,0x71,0xC0,0x92,0x39,
    0x00,0x0F,0xFF,0xFF,0xFE,0x07,0x07,0x04,0x41,0xC4,0x63,0xE4,0x71,0xC0,0x92,0x39,
    0x00,0x07,0xFF,0xFF,0xFC,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,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,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,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,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,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,0x00,0x00,0x00,0x00,0x00

    }; //图像数据

    /*****************************************
    *
    * N ms延时函数
    *
    ****************************************/
    void delay_nms(unsigned int n)
    {
    unsigned int i=0;
    for (i=0;i<n;i++)
    delay_1ms();
    }


    void write_com(unsigned int com)
    {
    //lcdrs = 0;
    P2OUT&= 0xfd;
    P1OUT = com;
    delay_nms(5);
    //lcden = 1;
    P2OUT|= 0x01;
    delay_nms(5);
    P2OUT&= 0xfe;
    }

    void write_dat(unsigned int dat)
    {
    //lcdrs = 1;
    P2OUT |= 0x02;
    P1OUT = dat;
    delay_nms(5);
    //lcden=1;
    P2OUT|= 0x01;
    delay_nms(5);
    // lcden=0;
    P2OUT&= 0xfe;

    }
    void disp_12864(uchar addr,const uchar *pt,uchar num)
    {
    uchar i;
    write_com(addr);
    for(i=0;i<(num*2);i++)
    write_dat(*(pt++));
    }
    void init()
    {
    //PSB=1;//并口模式
    P2OUT |= BIT2;
    delay_nms(15);
    //EN=0;
    P2OUT&= 0xfe;
    delay_nms(5);
    write_com(0x30);
    delay_nms(1);
    write_com(0x08);//清屏
    delay_nms(1);
    write_com(0x0c);//开显示,关光标
    delay_nms(1);
    write_com(0x01);
    delay_nms(1);
    write_com(0x06);//第一行显示位置
    delay_nms(1);
    }

    void lcd12864_image(const unsigned char *p)
    {
    int x,y;
    write_com(0x34); //扩展指令集动作,绘图显示OFF
    for (y=0;y<32;y++) //送上半屏显示数据
    {
    write_com(0x80|y); //送显示Y坐标0x80-0x9f
    write_com(0x80); //送显示X坐标0x80
    for (x=0;x<16;x++)
    {
    write_dat(*p);
    p++;
    }
    }

    for (y=0;y<32;y++) //送下半屏显示数据
    {
    write_com(0x80|y); //送显示Y坐标0x80-0x9f
    write_com(0x88); //送显示X坐标0x88
    for (x=0;x<16;x++)
    {
    write_dat(*p);
    p++;
    }
    }
    write_com(0x36); //扩展指令集动作,绘图显示ON
    }

    void main(void)
    {
    WDTCTL = WDTPW + WDTHOLD; // Stop WDT
    P1DIR |= 0xff; // P1.2 output
    P2DIR |= 0xff;
    init();

    write_com(0x01); //清除显示(清零DDRAM)

    lcd12864_image(ucpic); //送图像显示数据
    delay_nms(5000);
    while(1);
    }

点赞  2012-5-30 11:30
很敬业,加油!
点赞  2012-5-31 17:10

回复 板凳 lxttian 的帖子

多谢支持啊 多谢
点赞  2012-5-31 22:02
很好,顶一下
点赞  2012-6-1 09:39

回复 5楼 yzl624358 的帖子

x谢谢支持 谢谢
点赞  2012-6-1 14:07

回复 沙发 常见泽1 的帖子

unsigned char table[]=\"EE-LaunchPad\";数组这样定义会报错啊
点赞  2012-7-12 21:27

回复 7楼 tanfeng193 的帖子

把斜杠去掉 这个代码输入的格式 有问题 我复制进去的是没有斜杠的
unsigned char table[]="EE-LaunchPad"; 我输入的是这个 但是用代码格式输入会出现那个斜杠
点赞  2012-7-13 09:19

学弟一直没看懂~

请问  程序中的
void disp_12864(uchar addr,const uchar *pt,uchar num)
{
uchar i;
write_com(addr);
for(i=0;i<(num*2);i++)
write_dat(*(pt++));
}

这个子程序是什么作用啊?
点赞  2012-7-29 16:11
放这么大的一个数组,IAR编译器会说堆栈溢出怎么办?
点赞  2012-7-29 16:38

回复 10楼 暴风雪282 的帖子

我的木有提示 溢出 你用的2231?
点赞  2012-7-30 15:37
不好意思啊,看不到我的消息回复...我用的是2553啊,还是放不下,说是要压缩.
点赞  2012-8-2 21:23
好崇拜你啊
点赞  2012-8-7 13:57
来个串口的啊
点赞  2012-8-7 14:41

回复 沙发常见泽1 的帖子

谢过。。
点赞  2013-8-3 15:42
厉害,板凳板凳
点赞  2014-10-29 17:37
其实可以使用网页版ps,调整一下阈值,可以获得更好的取模效果
点赞  2014-11-2 15:13
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复