找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3056|回复: 0
打印 上一主题 下一主题
收起左侧

msp430f6638LCD数码显示

[复制链接]
跳转到指定楼层
楼主
ID:94349 发表于 2015-11-1 21:36 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
  1. #include "msp430f6638.h"
  2. #define d 0x01
  3. #define c 0x20
  4. #define b 0x40
  5. #define a 0x80
  6. #define dp 0x10
  7. #define g 0x04
  8. #define f 0x08
  9. #define e 0x02
  10. const char char_gen[]={
  11.   a+b+c+d+e+f,//0
  12.   b+c,        //1
  13.   a+b+d+e+g,  //2
  14.   a+b+c+d+g,  //3
  15.   b+c+f+g,    //4
  16.   a+f+g+c+d,  //5
  17.   a+c+d+f+e+g,  //6
  18.   a+b+c,        //7
  19.   a+b+c+d+e+f+g,//8
  20.   a+b+c+d+f+g}; //9
  21. void delay_ms(unsigned int ms)
  22. {
  23.   unsigned char m;
  24.   while(ms--)
  25.     for(m=0;m<100;m++);
  26. }
  27. void Init_lcd(void)
  28. {
  29.   LCDBCTL0 =LCDDIV0+LCDPRE0+LCDMX1+LCDSSEL+LCDMX1+LCD4MUX;
  30.   LCDBPCTL0=LCDS0+LCDS1+LCDS2+LCDS3+LCDS4+LCDS5+LCDS6+LCDS7
  31.             +LCDS8+LCDS9+LCDS10+LCDS11;
  32.   P5SEL =0xfc;
  33. }
  34. void LcdGo(unsigned char Dot)
  35. {
  36.    if(Dot==1)
  37.    {
  38.      //打开液晶显示
  39.      LCDBCTL0 |=LCDON;
  40.    }
  41.    else if(Dot==0)
  42.    {
  43.     LCDBCTL0 &=~LCDON;
  44.    }
  45. }
  46. /*显示消隐*/
  47. void Lcdblink(unsigned char doit)
  48. {
  49.    if(doit==0)
  50.    {
  51.      LCDBCTL0 &=~LCDSON;
  52.    }
  53.    else if(doit==1)
  54.    {
  55.       LCDBCTL0 |=LCDSON;
  56.    }
  57. }

  58. void LCD_clear(void)
  59. {
  60.    unsigned char index;
  61.    for(index=0;index<12;index++)
  62.    {
  63.      LCDMEM[index]=0;
  64.    }
  65. }
  66. void Backlight_enable(void)
  67. {
  68.   P5DIR |=BIT7;
  69.   P5OUT &=~BIT7;
  70. }

  71. int main( void )
  72. {
  73.   unsigned num,n;
  74.   // Stop watchdog timer to prevent time out reset
  75.   WDTCTL = WDTPW + WDTHOLD;
  76.   Init_lcd();
  77.   LcdGo(1);
  78.   //Lcdblink(1);
  79.   LCD_clear();
  80.   Backlight_enable();
  81.   while(1)
  82.   {      
  83.         for(num=0;num<3;num++)
  84.         {
  85.           for(n=0;n<4;n++)
  86.           {
  87.            LCDMEM[num*4+n]=char_gen[num*4+n];
  88.            delay_ms(1000);
  89.           }
  90.           LCD_clear();
  91.         }        
  92.   }
  93. }
复制代码


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 顶 踩
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表