51/AVR单片机技术驿站!  <在线翻译>     便利工具    特色网址   无弹窗、无插件的绿色站点...  英才招聘   学历查询  喜欢>>收藏我站 

当前位置:首页 > 单片机技术文章 > MSP430单片机 > 详细内容
分享MSP430与ST7529液晶显示控制器程序
发布时间:2009/7/27  阅读次数:1391  字体大小: 【】 【】【

  

/*--------------------------------------------------------------------------    
File Name:HG16016005T.C;    
Description:This Resouce Is For Dot Matrix Liquid Crystal    
                       Modules Controlled By SitronixS ST7529    
  
LCM Interface Dimenision:    
1             2             3             4             5             6             7             8             9             10    
----------------------------------------------------------------------------    
VSS         RS           R/W         E             /CS         /RST       VDD         D0           D1           D2    
  
11           12           13           14           15           16           17           18    
----------------------------------------------------------------------------    
D3           D4           D5           D6           D7           K             NC           A    
  
Author By:Dangzhen    
Date:2009-05-07    
--------------------------------------------------------------------------*/    
#include <msp430x14x.h>

#define DataPort           P1OUT        

#define led1_on()   P4OUT|=BIT7
#define led1_off() P4OUT^=BIT7

#define lcm_on P4OUT|=BIT5         //背光控制
#define lcm_off P4OUT^=BIT5

#define LCD_RS1 P4OUT|=BIT0       //RS 0:指令   1:数据
#define LCD_RS0 P4OUT&=~BIT0
  
#define LCD_RST1 P4OUT|=BIT4     //RESET
#define LCD_RST0 P4OUT&=~BIT4

#define LCD_WR1 P4OUT|=BIT1       //WR
#define LCD_WR0 P4OUT&=~BIT1

#define LCD_RD1 P4OUT|=BIT2     //RD
#define LCD_RD0 P4OUT=~BIT2

#define LCD_CS1 P4OUT|=BIT3       //CS
#define LCD_CS0 P4OUT&=~BIT3

#define           VOLCTRL         0x81       / *EC控制 2字节参数 D0~D5,D6~D8*/
#define           VOLUP             0xD6       /* EC减一 */
#define           VOLDOWN         0xD7       /* EC加一 */

#define   uchar unsigned char        
#define   uint   unsigned int    
#define   TRUE     1
#define   FALSE   0
      
#define DELAYMS         200          

/************************************************************
***************************函数定义*************************/
const uchar   HTDISPLAY[];
void delay();
void delayms();
void delay10ms(int count);
void wr_cmd(uchar cmd);
void wr_dat(uchar dat);
void ST7529Ini(void);
void HDT_DisplayOff();
void HDT_DisplayOn();
void InitSys();
void disp_dots(uchar dat1,uchar dat2);
void disp_bmpp( const uchar *myziku);
void LcdSetAddr16_16(uchar x1, uchar y1,   const uchar *ziku);
void dsiplay16_16(uchar x,uchar y);
const uchar MYNUMBER[];
void LcdSetAddr12_12(uchar x1, uchar y1,   const uchar *NUMBER);
/*--------------------------------------------------------------------------------*/

  const uchar   HTDISPLAY[]=    
{    
0x08,0x30,0x04,0x20,0x02,0x40,0x3F,0xFC,0x29,0x14,0x25,0x24,0x25,0x44,0x3F,0xFC,
0x00,0x00,0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,/*"曾",0*/
0x10,0x00,0x11,0xFC,0x20,0x08,0x20,0x10,0x48,0x30,0xF0,0xC8,0x13,0x06,0x20,0x02,
0x41,0xFC,0xF8,0x20,0x00,0x20,0x00,0x20,0x18,0x20,0xE3,0xFE,0x00,0x00,0x00,0x00,/*"经",1*/
0x01,0x00,0x01,0x00,0x7F,0xFE,0x02,0x00,0x04,0x00,0x0F,0xF0,0x18,0x10,0x28,0x10,
0x4F,0xF0,0x88,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x90,0x08,0x70,0x08,0x20,/*"有",2*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"一",3*/
0x09,0x30,0x0D,0xA0,0x09,0x20,0x12,0x10,0x12,0x08,0x24,0x0E,0x68,0x04,0xB7,0xF8,
0x20,0x88,0x20,0x88,0x20,0x88,0x21,0x08,0x21,0x08,0x22,0x38,0x2C,0x10,0x00,0x00,/*"份",4*/
0x01,0x00,0x01,0x04,0x7F,0xFE,0x02,0x00,0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x08,0x10,
0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x08,0x10,0xFF,0xFE,0x04,0x40,0x18,0x30,0x60,0x0C,/*"真",5*/
0x08,0x40,0x08,0x40,0x7E,0xF8,0x08,0x48,0x1E,0x48,0x68,0xCA,0x08,0xAA,0x2B,0x06,
0x1F,0xF0,0x01,0x00,0x3F,0xF8,0x01,0x00,0x7F,0xFE,0x01,0x00,0x05,0x00,0x02,0x00,/*"挚",6*/
0x10,0x80,0x10,0x80,0x20,0x80,0x7C,0xFC,0x45,0x04,0x45,0x04,0x46,0x04,0x7C,0x84,
0x44,0x44,0x44,0x64,0x44,0x24,0x44,0x04,0x7C,0x04,0x44,0x28,0x40,0x10,0x00,0x00,/*"的",7*/
0x00,0xF8,0x3F,0x90,0x12,0x10,0x09,0x20,0x3F,0xFE,0x22,0x02,0x42,0x00,0x3F,0xFC,
0x04,0x00,0x07,0xF0,0x0C,0x20,0x0B,0x40,0x10,0xC0,0x63,0x30,0x8C,0x0E,0x30,0x04,/*"爱",8*/
0x20,0x40,0x20,0x40,0x27,0xFC,0x30,0x40,0xAB,0xF8,0xA0,0x40,0xAF,0xFE,0x20,0x00,
0x23,0xF8,0x22,0x08,0x23,0xF8,0x22,0x08,0x23,0xF8,0x22,0x08,0x22,0x28,0x22,0x10,/*"情",9*/
0x10,0x40,0x08,0x60,0x08,0x40,0xFE,0xFE,0x20,0x84,0x20,0x84,0x3D,0x44,0x26,0x48,
0x24,0x28,0x24,0x30,0x24,0x10,0x24,0x30,0x44,0x48,0x44,0x8E,0x95,0x04,0x08,0x00,/*"放",10*/
0x02,0x00,0x02,0x00,0x7F,0xFE,0x04,0x00,0x04,0x00,0x08,0x40,0x18,0x40,0x17,0xFC,
0x30,0x40,0x50,0x40,0x90,0x40,0x10,0x40,0x10,0x40,0x17,0xFE,0x10,0x00,0x00,0x00,/*"在",11*/
0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48,
0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02,/*"我",12*/
0x00,0x00,0x7F,0xFE,0x02,0x00,0x04,0x00,0x3F,0xFC,0x24,0x44,0x24,0x44,0x27,0xC4,
0x24,0x44,0x24,0x44,0x27,0xC4,0x24,0x44,0x24,0x44,0x3F,0xFC,0x20,0x04,0x00,0x00,/*"面",13*/
0x08,0x10,0x06,0x18,0x04,0x20,0xFF,0xFE,0x00,0x00,0x3E,0x08,0x22,0x48,0x3E,0x48,
0x22,0x48,0x22,0x48,0x3E,0x48,0x22,0x48,0x22,0x48,0x2A,0x08,0x24,0x28,0x00,0x10,/*"前",14*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x10,0x00,0x20,0x00,0x00,0x00,/*",",15*/
0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48,
0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02,/*"我",16*/
0x20,0x00,0x11,0xF0,0x11,0x10,0x81,0x10,0x42,0x12,0x54,0x0E,0x10,0x00,0x17,0xF8,
0x22,0x10,0x21,0x10,0xE0,0xA0,0x20,0x40,0x20,0xA0,0x21,0x18,0x26,0x0E,0x20,0x04,/*"没",17*/
0x01,0x00,0x01,0x00,0x7F,0xFE,0x02,0x00,0x04,0x00,0x0F,0xF0,0x18,0x10,0x28,0x10,
0x4F,0xF0,0x88,0x10,0x08,0x10,0x0F,0xF0,0x08,0x10,0x08,0x90,0x08,0x70,0x08,0x20,/*"有",18*/
0x10,0x00,0x11,0xFC,0x10,0x08,0x10,0x10,0xFC,0x20,0x24,0x20,0x24,0x20,0x27,0xFE,
0x44,0x20,0x64,0x20,0x18,0x20,0x08,0x20,0x14,0x20,0x26,0x20,0x44,0xA0,0x80,0x40,/*"好",19*/
0x10,0x00,0x11,0xFC,0x10,0x08,0x10,0x10,0xFC,0x20,0x24,0x20,0x24,0x20,0x27,0xFE,
0x44,0x20,0x64,0x20,0x18,0x20,0x08,0x20,0x14,0x20,0x26,0x20,0x44,0xA0,0x80,0x40,/*"好",20*/
0x00,0x40,0xF8,0x40,0x20,0xA0,0x21,0x10,0x22,0x28,0x24,0x46,0xF8,0x80,0x23,0x10,
0x20,0x24,0x20,0x44,0x39,0x88,0xC6,0x10,0x00,0x60,0x01,0x80,0x06,0x00,0x38,0x00,/*"珍",21*/
0x21,0x10,0x21,0x10,0x21,0x10,0x37,0xFC,0xA9,0x10,0xA1,0x10,0xAF,0xFE,0x20,0x00,
0x23,0xF8,0x22,0x08,0x22,0x08,0x23,0xF8,0x22,0x08,0x22,0x08,0x23,0xF8,0x00,0x00,/*"惜",22*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,/*"!",23*/
0x10,0x00,0x10,0x00,0x18,0x00,0x10,0x7E,0xFE,0x42,0x22,0x42,0x22,0x42,0x22,0x42,
0x22,0x42,0x24,0x42,0x14,0x42,0x08,0x42,0x14,0x7E,0x23,0x42,0x42,0x42,0x80,0x00,/*"如",24*/
0x00,0x00,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x00,0x01,0x00,
0xFF,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xC1,0x04,0x01,0x00,0x01,0x00,/*"果",25*/
0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0xF8,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0x7F,0xFE,0x00,0x00,/*"上",26*/
0x00,0x00,0x3F,0xFC,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x7F,0xFE,0x01,0x00,
0x01,0x00,0x02,0x80,0x02,0x40,0x04,0x20,0x08,0x18,0x10,0x0E,0x20,0x04,0x40,0x00,/*"天",27*/
0x20,0x40,0x30,0x40,0x24,0x4C,0x42,0x70,0xFF,0x44,0x42,0x46,0x00,0x7C,0x7E,0x00,
0x42,0x40,0x7E,0x4C,0x42,0x70,0x7E,0x40,0x42,0x44,0x42,0x46,0x4A,0x3C,0x44,0x00,/*"能",28*/
0x7F,0xFC,0x01,0x00,0x01,0x00,0x1F,0xF0,0x11,0x10,0x11,0x10,0x1F,0xF0,0x11,0x10,
0x11,0x10,0x11,0x10,0xFF,0xFE,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x50,0x10,0x20,/*"再",29*/
0x10,0x40,0x10,0x40,0x20,0xA0,0x20,0x90,0x49,0x08,0xF2,0x0E,0x15,0xF4,0x20,0x00,
0x40,0x00,0xF9,0xF8,0x01,0x08,0x01,0x08,0x19,0x08,0xE1,0x08,0x01,0xF8,0x00,0x00,/*"给",30*/
0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48,
0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02,/*"我",31*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"一",32*/
0x01,0x00,0x41,0x00,0x25,0x00,0x25,0xFE,0x2A,0x44,0x0A,0x48,0x14,0x40,0x10,0x40,
0x20,0xC0,0xE0,0xA0,0x41,0x20,0x42,0x10,0x44,0x08,0x18,0x0E,0x60,0x04,0x00,0x00,/*"次",33*/
0x10,0x00,0x10,0xF8,0x10,0x88,0xFE,0x88,0x10,0x88,0x10,0x88,0x38,0x88,0x34,0x88,
0x54,0x88,0x50,0x88,0x91,0x08,0x11,0x0A,0x12,0x0A,0x12,0x0A,0x14,0x06,0x10,0x00,/*"机",34*/
0x01,0x00,0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x10,0x18,0x6F,0xEE,0x80,0x04,
0x00,0x00,0x3F,0xF8,0x02,0x00,0x04,0x20,0x08,0x10,0x11,0xF8,0x3F,0x18,0x10,0x10,/*"会",35*/
0x10,0x80,0x10,0x80,0x20,0x80,0x7C,0xFC,0x45,0x04,0x45,0x04,0x46,0x04,0x7C,0x84,
0x44,0x44,0x44,0x64,0x44,0x24,0x44,0x04,0x7C,0x04,0x44,0x28,0x40,0x10,0x00,0x00,/*"的",36*/
0x40,0x00,0x20,0x1C,0x33,0xE0,0x20,0x20,0x00,0x20,0x07,0xFE,0xF0,0x20,0x10,0x20,
0x10,0x20,0x11,0xFC,0x11,0x04,0x11,0x04,0x15,0x04,0x19,0xFC,0x11,0x04,0x00,0x00,/*"话",37*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x10,0x00,0x20,0x00,0x00,0x00,/*",",38*/
0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48,
0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02,/*"我",39*/
0x01,0x00,0x01,0x00,0x02,0x80,0x04,0x40,0x08,0x20,0x10,0x18,0x6F,0xEE,0x80,0x04,
0x00,0x00,0x3F,0xF8,0x02,0x00,0x04,0x20,0x08,0x10,0x11,0xF8,0x3F,0x18,0x10,0x10,/*"会",40*/
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0xFF,0xFE,0x01,0x00,0x02,0x80,
0x02,0x80,0x02,0x40,0x04,0x40,0x04,0x20,0x08,0x10,0x10,0x18,0x20,0x0E,0x40,0x04,/*"大",41*/
0x01,0x00,0xFF,0xFE,0x01,0x00,0x01,0x00,0x7F,0xFC,0x00,0x00,0x3F,0xF8,0x21,0x08,
0x21,0x08,0x3F,0xF8,0x20,0x08,0x20,0x00,0x40,0x00,0x40,0x00,0x80,0x00,0x00,0x00,/*"声",42*/
0x00,0x10,0x00,0x10,0x7C,0x10,0x04,0x10,0x05,0xFE,0x44,0x10,0x24,0x10,0x19,0x10,
0x08,0x90,0x14,0xD0,0x24,0x90,0x22,0x10,0x42,0x10,0x80,0x10,0x00,0x50,0x00,0x20,/*"对",43*/
0x00,0x20,0x20,0xA0,0x20,0xA0,0x20,0xA4,0xFC,0xBE,0x27,0xE4,0x24,0xA4,0x44,0xA4,
0x44,0xA4,0x48,0xB4,0x28,0xA8,0x10,0xA0,0x28,0x82,0x46,0x82,0x84,0x7E,0x00,0x00,/*"她",44*/
0x42,0x08,0x21,0x88,0x31,0x10,0x23,0xF8,0x02,0x08,0xE2,0x08,0x22,0x08,0x23,0xF8,
0x22,0xA8,0x20,0xA0,0x20,0xA0,0x29,0x20,0x31,0x22,0x22,0x22,0x04,0x1E,0x08,0x00,/*"说",45*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x00,0x00,0x00,0x00,/*":",46*/
0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48,
0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02,/*"我",47*/
0x00,0xF8,0x3F,0x90,0x12,0x10,0x09,0x20,0x3F,0xFE,0x22,0x02,0x42,0x00,0x3F,0xFC,
0x04,0x00,0x07,0xF0,0x0C,0x20,0x0B,0x40,0x10,0xC0,0x63,0x30,0x8C,0x0E,0x30,0x04,/*"爱",48*/
0x09,0x00,0x09,0x80,0x11,0x04,0x13,0xFE,0x22,0x04,0x34,0x48,0x68,0x40,0xA2,0x50,
0x23,0x48,0x22,0x48,0x24,0x44,0x24,0x46,0x28,0x44,0x21,0x40,0x20,0x80,0x00,0x00,/*"你",49*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,/*"!",50*/
0x10,0x00,0x10,0x00,0x18,0x00,0x10,0x7E,0xFE,0x42,0x22,0x42,0x22,0x42,0x22,0x42,
0x22,0x42,0x24,0x42,0x14,0x42,0x08,0x42,0x14,0x7E,0x23,0x42,0x42,0x42,0x80,0x00,/*"如",51*/
0x00,0x00,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x11,0x10,0x1F,0xF0,0x01,0x00,0x01,0x00,
0xFF,0xFE,0x03,0x80,0x05,0x40,0x09,0x30,0x31,0x0E,0xC1,0x04,0x01,0x00,0x01,0x00,/*"果",52*/
0x04,0x40,0x04,0x40,0x04,0x40,0x7C,0x7E,0x04,0x40,0x04,0x40,0x04,0x40,0x7C,0x7C,
0x04,0x40,0x04,0x40,0x04,0x40,0xFC,0x7E,0x04,0x40,0x04,0x40,0x04,0x40,0x04,0x40,/*"非",53*/
0x00,0x00,0xFF,0xFE,0x04,0x40,0x3F,0xF8,0x24,0x48,0x24,0x48,0x3F,0xF8,0x24,0x08,
0x04,0x00,0xFF,0xFE,0x08,0x10,0x0E,0x20,0x01,0xC0,0x06,0x30,0x18,0x0C,0x60,0x08,/*"要",54*/
0x08,0x00,0x08,0x00,0x08,0x00,0x7F,0x7C,0x09,0x44,0x09,0x44,0x09,0x44,0x09,0x44,
0x11,0x44,0x11,0x44,0x11,0x44,0x21,0x44,0x21,0x7C,0x45,0x44,0x82,0x40,0x00,0x00,/*"加",55*/
0x00,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0xF8,0x01,0x00,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x04,0x7F,0xFE,0x00,0x00,/*"上",56*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"一",57*/
0x01,0x00,0x01,0x00,0x02,0x80,0x02,0x40,0x04,0x20,0x09,0x18,0x11,0x0E,0x61,0x04,
0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x01,0x00,0x00,0x00,/*"个",58*/
0x22,0x00,0x22,0x7C,0x7F,0x44,0x22,0x44,0x3E,0x44,0x22,0x7C,0x3E,0x44,0x22,0x44,
0x22,0x44,0xFF,0x7C,0x00,0x44,0x24,0x84,0x22,0x84,0x43,0x14,0x81,0x08,0x00,0x00,/*"期",59*/
0x00,0x00,0xFB,0xF8,0x92,0x08,0x93,0xF8,0xA2,0x08,0xA2,0x08,0x93,0xF8,0x8A,0x80,
0x8A,0x48,0xAA,0x50,0x92,0x20,0x82,0x20,0x82,0x10,0x82,0x8E,0x83,0x04,0x82,0x00,/*"限",60*/
0x10,0x80,0x10,0x80,0x20,0x80,0x7C,0xFC,0x45,0x04,0x45,0x04,0x46,0x04,0x7C,0x84,
0x44,0x44,0x44,0x64,0x44,0x24,0x44,0x04,0x7C,0x04,0x44,0x28,0x40,0x10,0x00,0x00,/*"的",61*/
0x40,0x00,0x20,0x1C,0x33,0xE0,0x20,0x20,0x00,0x20,0x07,0xFE,0xF0,0x20,0x10,0x20,
0x10,0x20,0x11,0xFC,0x11,0x04,0x11,0x04,0x15,0x04,0x19,0xFC,0x11,0x04,0x00,0x00,/*"话",62*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x30,0x00,0x30,0x00,0x10,0x00,0x20,0x00,0x00,0x00,/*",",63*/
0x06,0x40,0x38,0x50,0x08,0x48,0x08,0x48,0x08,0x40,0xFF,0xFE,0x08,0x40,0x08,0x48,
0x0E,0x28,0x38,0x30,0xC8,0x20,0x08,0x50,0x09,0x92,0x08,0x0A,0x28,0x06,0x10,0x02,/*"我",64*/
0x08,0x20,0x06,0x40,0x01,0x80,0x0E,0x60,0x32,0x10,0xFF,0xFE,0x04,0x80,0x08,0x80,
0x1F,0xF8,0x28,0x88,0x48,0x88,0x88,0x88,0x08,0x88,0x08,0xB8,0x00,0x90,0x00,0x80,/*"希",65*/
0x10,0x00,0x08,0xFC,0xFE,0x84,0x20,0xFC,0x20,0x84,0x24,0xFC,0x28,0x84,0x31,0x1C,
0x00,0x00,0x3F,0xFC,0x01,0x00,0x1F,0xF8,0x01,0x00,0x01,0x00,0x7F,0xFE,0x00,0x00,/*"望",66*/
0x00,0x00,0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x08,0x10,0x0F,0xF0,0x00,0x00,0xFF,0xFE,
0x01,0x00,0x09,0x00,0x09,0xF8,0x09,0x00,0x15,0x00,0x23,0x00,0x40,0xFE,0x00,0x00,/*"是",67*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x7F,0xFE,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,/*"一",68*/
0x00,0x00,0x7F,0xFE,0x02,0x00,0x02,0x00,0x02,0x10,0x03,0xF8,0x02,0x10,0x04,0x10,
0x04,0x10,0x04,0x10,0x08,0x10,0x08,0x10,0x10,0x10,0x20,0xE0,0x40,0x40,0x00,0x00,/*"万",69*/
0x08,0x00,0x0F,0xFC,0x10,0x80,0x10,0x80,0x20,0x80,0x4F,0xF8,0x88,0x80,0x08,0x80,
0x08,0x80,0x08,0x80,0xFF,0xFE,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x80,/*"年",70*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,
0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x10,0x00,0x00,0x00,/*"!",71*/

};    

const uchar MYNUMBER[]=
{

0x00,0x00,0x70,0x88,0x88,0x88,0x88,0x88,0x88,0x70,0x00,0x00,/*"0",0*/
0x00,0x00,0x20,0x60,0x20,0x20,0x20,0x20,0x20,0x70,0x00,0x00,/*"1",1*/
0x00,0x00,0x70,0x88,0x88,0x10,0x20,0x40,0x80,0xF8,0x00,0x00,/*"2",2*/
0x00,0x00,0x70,0x88,0x08,0x30,0x08,0x08,0x88,0x70,0x00,0x00,/*"3",3*/
0x00,0x00,0x10,0x30,0x50,0x50,0x90,0x78,0x10,0x18,0x00,0x00,/*"4",4*/
0x00,0x00,0xF8,0x80,0x80,0xF0,0x08,0x08,0x88,0x70,0x00,0x00,/*"5",5*/
0x00,0x00,0x70,0x90,0x80,0xF0,0x88,0x88,0x88,0x70,0x00,0x00,/*"6",6*/
0x00,0x00,0xF8,0x90,0x10,0x20,0x20,0x20,0x20,0x20,0x00,0x00,/*"7",7*/
0x00,0x00,0x70,0x88,0x88,0x70,0x88,0x88,0x88,0x70,0x00,0x00,/*"8",8*/
0x00,0x00,0x70,0x88,0x88,0x88,0x78,0x08,0x48,0x70,0x00,0x00,/*"9",9*/
  };

///////////////////LCD的写字测试程序///16×16//////////////////
//横向点18位,最后两位填0////液晶驱动变态///////////
void disp_bmpp( const uchar *myziku)    
{    
       uchar x,y;
       uchar uc_CharCode,uc_BitCnt;    
      
       wr_cmd(0x30);//EXT=0        
      
       wr_cmd(0x75);     //Line address set        
       wr_dat(0x00);     //Start Line        
       wr_dat(0x0F); //End Line        
      
       wr_cmd(0x15);     //Column address set        
       wr_dat(0x00);     //Start Column        
       wr_dat(0x05);     //End Column        
      
       wr_cmd(0X5C);//Write data to DDRAM        

   for(x=0;x<16;x++)
   {
       for(y=0;y<2;y++)
       {
                       uc_CharCode = *myziku++;    
                                                                                                                                                                              
                   for(uc_BitCnt=0;uc_BitCnt<8;uc_BitCnt++)    
                           {    
                             if((uc_CharCode&0x80) == 0)    
                                   wr_dat(0x00);    
                                     else    
                                     wr_dat(0xFF);    
                                 //仅仅点亮panel上面的一个点---需要一个byte        
                               uc_CharCode =uc_CharCode <<1;    
                             }
                  
       }
       wr_dat(0x00);
       wr_dat(0x00);
   }
   delayms(1);
}


/*******************************************************
* 名称: LcdSetAddr
* 功能: 设置数据地址指针(坐标值)。
* 入口参数: x1                       起始横坐标的值 (0-158)
*                     y1           起始纵坐标的值 (0-158)
* 出口参数: 设置正确返回TRUE,参数超出范围返回FALSE
*******************************************************/
void LcdSetAddr16_16(uchar x1, uchar y1,   const uchar *ziku)
{    
     uchar x,y;
     uchar uc_CharCode,uc_BitCnt;
  
     wr_cmd(0x30);       //EXT=0

     wr_cmd(0x75);                                                    
     wr_dat(x1);
     wr_dat(x1+15);
      
     wr_cmd(0x15);                                                        
     wr_dat(y1);
     wr_dat(y1+5);
      
     wr_cmd(0X5C);                                                 //Write data to DDRAM
     for(x=0;x<16;x++)
     {
       for(y=0;y<2;y++)
           {
                   uc_CharCode =   *ziku++;    
                                                                                                                                                                              
                   for(uc_BitCnt=0;uc_BitCnt<8;uc_BitCnt++)    
                           {    
                             if((uc_CharCode&0x80) == 0)    
                                   wr_dat(0x00);    
                                     else    
                                     wr_dat(0xFF);    
                                 //仅仅点亮panel上面的一个点---需要一个byte        
                               uc_CharCode =uc_CharCode <<1;    
                             }
                  
             }
       wr_dat(0x00);
       wr_dat(0x00);
     }
       // if(((x1+15)<160) && ((y1+5)<53)) return(TRUE);
     //   else   return(FALSE);
}

void LcdSetAddr12_12(uchar x1, uchar y1,   const uchar *ziku)
{    
     uchar x;
     uchar uc_CharCode,uc_BitCnt;
     wr_cmd(0x30);       //EXT=0

     wr_cmd(0x75);                                                    
     wr_dat(x1);
     wr_dat(x1+11);
      
     wr_cmd(0x15);                                                        
     wr_dat(y1);
     wr_dat(y1+2);
      
     wr_cmd(0X5C);                                                 //Write data to DDRAM
     for(x=0;x<12;x++)
     {
      
                   uc_CharCode = *ziku++;    
                                                                                                                                                                              
                   for(uc_BitCnt=0;uc_BitCnt<8;uc_BitCnt++)    
                           {    
                             if((uc_CharCode&0x80) == 0)    
                                   wr_dat(0x00);    
                                     else    
                                     wr_dat(0xFF);    
                                 //仅仅点亮panel上面的一个点---需要一个byte        
                               uc_CharCode =uc_CharCode <<1;    
                             }
       wr_dat(0x00);
     }
       // if(((x1+15)<160) && ((y1+5)<53)) return(TRUE);
     //   else   return(FALSE);
}

//Reset Delay              
void delay()    
{    
       uchar uc_dlay1,uc_dlay2;    
       for (uc_dlay1=0; uc_dlay1<250; uc_dlay1++);    
               for (uc_dlay2=0; uc_dlay2<20; uc_dlay2++);    
}    
      
//Delay Times(s Level)              
void delayms()    
{    
       uint ui_dlay1,ui_dlay2;    
       ui_dlay2 = DELAYMS;    
       while (ui_dlay2-- >0)    
       {    
               for (ui_dlay1=0; ui_dlay1<500; ui_dlay1++);    
               for (ui_dlay1=0; ui_dlay1<500; ui_dlay1++);    
       }    
}    

void delay10ms(int count)     //===延迟===
{
unsigned int i,j,k;
for (i=0; i<count; i++);
   for(j=0; j<10; j++);
       for(k=0; k<120; k++);
}

//Write Instruction Code              
void wr_cmd(uchar cmd)    
{    
       LCD_RS0;    
      
       LCD_WR1;    
      
       LCD_RD1;    
      
       LCD_CS0;    
      
       DataPort = cmd;    
      
       LCD_WR0;    
      
       LCD_WR1;    
      
       LCD_CS1;    
}    
      
//Write Display RAM Data          
void wr_dat(uchar dat)    
{    
      
       LCD_RS1;    
      
       LCD_WR1;    
      
       LCD_RD1;    
      
       LCD_CS0;    
      
       DataPort = dat;    
      
       LCD_WR0;    
      
       LCD_WR1;    
      
       LCD_CS1;    
      
}    

void InitSys()
{
     unsigned int iq0;                                     //--- 使用XT2振荡器 ---
     BCSCTL1&=~XT2OFF;                                     //=== 打开XT2振荡器 ===
     do
     {
     IFG1 &= ~OFIFG;                                         //=== 清除振荡器失效标志 ===
     for (iq0 = 0xFF; iq0 > 0; iq0--);     //=== 延时,等待XT2起振 ===
   }
   while ((IFG1 & OFIFG) != 0);                 //=== 判断XT2是否起振 ===
   BCSCTL2 =SELM_2+SELS;                               //=== 选择MCLK、SMCLK为XT2 ===
//--- 以下填充用户代码,对各种模块、中断、外围设备等进行初始化 ---
   P1SEL   = 0x00;                                           // 设置P1口为IO口
   P1DIR   = 0xFF;                                           // 设置P1口为output
   P4DIR   = 0xFF;                                           //===Set P4.0 to output direction===
          
   //   _EINT();                                                       //=== 打开全局中断控制,若不需要打开,可以屏蔽本句 ===
}

/*******************************************************************************    
*    
*     函数名称       :     ST7529Ini(void)    
*     功能描述       :     初始化控制器    
*     函数说明       :    
*     调用函数       :     无    
*     全局变量       :     无    
*     输入参数       :     无    
*     返回值         :     无    
*     设计者         :     Joshua Chiang    
*     修改者         :     --    
*     版本号         :     1.0    
*    
*******************************************************************************/              
void ST7529Ini(void)    
{    
       wr_cmd(0X30);     //EXT=0        
       wr_cmd(0X94);     //SLEEP OUT        
       wr_cmd(0XD1);     //OSC ON        
      

       wr_cmd(0x20);     //POWER CONTROL SET        
       wr_dat(0X0B);     //BOOSTER ON        
      
       wr_cmd(0x81);     //ELECTRONIC CONTROL        
       wr_dat(0X30);     //DL       30
       wr_dat(0X04);     //DH        
      
       wr_cmd(0xCA);     //DISPLAY CONTROL        
       wr_dat(0X04);     //CLD=0,NOT DIVIDE        
       wr_dat(0X27);     //1/160 DUTY 39        
       wr_dat(0X00);     //FR        
      
       wr_cmd(0xA7);     //Reverse display   ~A6?    
      
       wr_cmd(0xBB);     //COM SCAN DIRECTION        
       wr_dat(0X02);     //C79->C0,C80->C159        
      
       wr_cmd(0xBC);     //Data Scan Direction        
       wr_dat(0X01);    
       wr_dat(0X00);     //CLR=0        
       wr_dat(0X02);     //32 Gray-scale 3byte 3pixel mode        
      
       wr_cmd(0x75);     //Line address set        
       wr_dat(0x00);     //Start Line        
       wr_dat(0x9F);     //End Line        
      
       wr_cmd(0x15);     //Column address set        
       wr_dat(0x00);     //Start Column        
       wr_dat(0x35);     //End Column        
      
       wr_cmd(0x31);     //ext=1        
       wr_cmd(0x32);     //Analog circuit set        
       wr_dat(0X07);     //FR=12.7KHZ        
       wr_dat(0X02);     //Booster FR=6KHZ        
       wr_dat(0X03);     //1/11bias     01 调对比度
      
       wr_cmd(0x34);     //Dithering off        
       wr_cmd(0x30);     //EXT=0        
       wr_cmd(0xAF);     //DISP ON        
               }    
      
//Write Data To DDRAM              
void disp_dots(uchar dat1,uchar dat2)    
{    
       uchar uc_RowCnt,uc_ColCnt;    
       wr_cmd(0x30);//EXT=0        
      
       wr_cmd(0x75);     //Line address set        
       wr_dat(0x00);     //Start Line        
       wr_dat(0x9F);     //End Line        
      
       wr_cmd(0x15);     //Column address set        
       wr_dat(0x00);     //Start Column        
       wr_dat(0x35);     //End Column        
      
       wr_cmd(0X5C);//Write data to DDRAM        
      
       for (uc_RowCnt=0;uc_RowCnt<80;uc_RowCnt++)    
       {    
               for (uc_ColCnt=0;uc_ColCnt<54;uc_ColCnt++)    
               {    
                               wr_dat(dat1);    
                               wr_dat(dat1);    
                               wr_dat(dat1);    
               };    
      
               for (uc_ColCnt=0;uc_ColCnt<54;uc_ColCnt++)    
               {    
                               wr_dat(dat2);    
                               wr_dat(dat2);    
                               wr_dat(dat2);    
               };    
       };    
      
       delayms();    
}

void dsiplay16_16(uchar x,uchar y)
  {
     const uchar *z;
     z=HTDISPLAY;
     for(;x<145;x+=16)
     {
         for(;y<50;y+=6)
       {
           LcdSetAddr16_16(x,   y, z);
           z+=32;
         }
         y=0;
     }
  }
/*
功能:设置液晶开关
参数:无
返回:无
*/
void HDT_DisplayOn()
{
       wr_cmd(0xaf);
       //wr_cmd(0x94);
       led1_on();
       lcm_on;
}

void HDT_DisplayOff()
{
       wr_cmd(0xae);
       //wr_cmd(0x95);
       led1_off();
       lcm_off;
}
  
void main()    
{          
       WDTCTL   = WDTPW + WDTHOLD;     //=== Stop watchdog timer ===
       InitSys();                                     //=== 初始化 ===
       LCD_RST0;    
       delay();    
       delay();    
      
       LCD_RST1;    
       delay();    
       delay();    
      
       ST7529Ini();    
      
       while (1)    
       {    
               disp_dots(0xFF,0xFF); //All Dots Display        
      
               disp_dots(0xFF,0x00); //Seperate Rows I        
                  
               HDT_DisplayOff();
               HDT_DisplayOn();
               disp_dots(0x00,0xFF); //Seperate Rows II          
      
               disp_dots(0x00,0x00); //Clear Screen    
               dsiplay16_16(0,0);
                
               LcdSetAddr12_12(0, 6,HTDISPLAY);
               disp_bmpp(&HTDISPLAY[32]);
                
               LcdSetAddr16_16(16, 0, HTDISPLAY );
               LcdSetAddr12_12(0, 18,MYNUMBER);
       }    
      
}

我要评论
  • 匿名发表
  • [添加到收藏夹]
  • 发表评论:(匿名发表无需登录,已登录用户可直接发表。) 登录状态:未登录
最新评论
所有评论[0]
    暂无已审核评论!

网站导航 管理登陆 ┊ 免责声明 问题反馈  友链说明
本站部分内容来自网络共享资源,如有冒犯您的权利请来信告之删除或纠正!
不得对本站进行复制、盗链或镜像,转载内容须获得同意或授权;欢迎友情链接、站务合作!

    我要报警 Alexa
 mcusy_cn#126.com (请把#改成@) 交流:522422171
本站学习交流群:138..158(高级群1-)、77930286(高级群2)、61804809(群3)
Copyright© MCUSY All Rights Reserved
本站网警备案号: WZ36040002485
  ICP备案证书号:粤ICP备09034963号