⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcd年月日星期时间1.c

📁 430开发板点阵操作源程序
💻 C
字号:
#include "msp430x44x.h"
//*********************************************************************
//MSP-Test44x Demo    LCD matrix dispaly the char and logo(lsd)
//
//
//                  MSP430F449
//             -----------------
//         /|\|              XIN|-
//          | |                 |
//          --|RST          XOUT|-   ________
//            |                 |   |        |
//            |             P2.0|-->|   l    |
//            |               . | . |        |
//            |             P2.3| . |   C    |
//            |             P2.6| . |        |
//            |             P2.7| . |   D    |
//            |             P3.0| . |        |
//            |               . | . |        |
//            |             P3.8|-->|________|
//            |                 |
//  zhangchong
//  Lierda, Inc
//  February 2006.03
//  Built with IAR Embedded Workbench Version: 3.40a
//  ID:  MSP430-TEST44X
//  DATA:2005-7-12
//  REV: 2.0A
//  程序功能:该程序是用F449来控制对128X64点阵的片选CS1,CS2,数据线D0-D7,读写信号等的操作?//            来对点阵的操作,具体内容如“利尔达,TEL:0571 -88800000。具体详浏览程序描述
//  硬件连接:必须连接F449边上的p3.0-P3.7,P4.0,P4.1,P2.6,P2.7口上的短接器。另外,可以通过3296电位器R20来调节LCD灰度。
//
//typedef unsigned long DWORD;
typedef unsigned int  WORD;
typedef unsigned char BYTE;
//****************************************************************************
//****************************************************************************
//****************************************************************************
#define		P2_0_RS			0x01
#define		P2_1_RW			0x02
#define		P2_2_EN			0x04
#define		P2_3_CS1		0x08
#define		P2_3_CS2		0x40
#define		P2_3_RST		0x80

#define		P3_0_DB0		0x01
#define		P3_1_DB1		0x02
#define		P3_2_DB2		0x04
#define		P3_3_DB3		0x08
#define		P3_4_DB4		0x10
#define		P3_5_DB5		0x20
#define		P3_6_DB6		0x40
#define		P3_7_DB7		0x80

//****************************************************************************
//****************************************************************************
//****************************************************************************
const BYTE Char_Position[4][12]=
{
	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
	0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
	0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4A, 0x4B,
	0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B
};

const BYTE CHAR_0[5]={0x3E,0x51,0x49,0x45,0x3E};
const BYTE CHAR_1[5]={0x00,0x42,0x7F,0x40,0x00};
const BYTE CHAR_2[5]={0x42,0x61,0x51,0x49,0x66};
const BYTE CHAR_3[5]={0x23,0x41,0x45,0x4B,0x31};
const BYTE CHAR_4[5]={0x18,0x14,0x52,0x7F,0x50};
const BYTE CHAR_5[5]={0x27,0x45,0x45,0x45,0x39};
const BYTE CHAR_6[5]={0x3C,0x4A,0x49,0x49,0x30};
const BYTE CHAR_7[5]={0x03,0x71,0x09,0x05,0x03};
const BYTE CHAR_8[5]={0x36,0x49,0x49,0x49,0x36};
const BYTE CHAR_9[5]={0x06,0x49,0x49,0x29,0x1E};

const BYTE CHAR_A[5]={0x7E,0x11,0x11,0x11,0x7E};
const BYTE CHAR_B[5]={0x7F,0x49,0x49,0x49,0x36};

const BYTE CHAR_T[5]={0x03,0x41,0x7F,0x41,0x03};
const BYTE CHAR_E[5]={0x41,0x7F,0x49,0x5D,0x63};
const BYTE CHAR_L[5]={0x41,0x7F,0x41,0x40,0x60};
const BYTE Symbols[20][5]=
{
	0x00,0x36,0x36,0x00,0x00,		// [0]':'
	0x00,0x08,0x08,0x08,0x00		// [1]'-'
};

const BYTE Nianyueri[7][38]=
{                                                    // 显示  年月日
        0x80,0x88,0x8C,0xF4,0xF6,0x97,0x97,0x97,0xFE,0xFE,0x96,0x96,0x96,0x96,0x96,0x96,0x80,0x80,0x80,
        0x01,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0x00,0x00,0x00,0x00,0x01,0x01,0x01,0x01,0x01,

        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,0xFF,0x92,0x92,0x92,0x92,0x92,0x92,0xFF,0xFF,0x06,
        0x00,0x00,0x00,0x04,0x0C,0x0C,0x0E,0x07,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x1F,0x0C,


        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0xFE,0x62,0x62,0x42,0x42,0x62,0x62,0xFE,0xFE,0x02,
        0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0F,0x0F,0x0C,0x0C,0x04,0x04,0x0C,0x0C,0x0F,0x0F,0x00,

        0x00,0x00,0x80,0xC2,0x7F,0x76,0x55,0x55,0xF5,0xF5,0x75,0x55,0x55,0x5F,0x5F,0x00,0x00,0x00,0x00,
        0x08,0x0D,0x0D,0x0E,0x0D,0x0D,0x0D,0x05,0x07,0x07,0x0D,0x0D,0x0D,0x0D,0x0D,0x08,0x18,0x18,0x08,

        0x00,0x80,0x84,0x86,0x86,0xFF,0xFF,0xAA,0xAA,0xFF,0xFF,0x82,0x80,0xFE,0x92,0x92,0x92,0xFE,0xFE,
        0x00,0x01,0x01,0x08,0x0C,0x06,0x02,0x00,0x0A,0x0A,0x0C,0x0C,0x07,0x01,0x00,0x00,0x00,0x1F,0x1F,

        0x04,0xFE,0x2C,0x24,0x24,0xFE,0x0C,0x18,0x58,0xD8,0x98,0x88,0x08,0xFF,0xFF,0x18,0x18,0x18,0x18,
        0x00,0x03,0x03,0x03,0x03,0x03,0x00,0x00,0x08,0x08,0x08,0x18,0x08,0x0F,0x07,0x00,0x00,0x00,0x00,

        0x00,0x00,0x80,0xFC,0x00,0x03,0xF2,0x90,0x94,0x96,0x92,0xF2,0xF2,0x02,0x02,0xFE,0xFE,0x00,0x00,
        0x0C,0x0E,0x0F,0x03,0x00,0x00,0x07,0x06,0x02,0x02,0x02,0x02,0x07,0x00,0x00,0x1F,0x1F,0x00,0x00,

        };

const BYTE Lierda_13_19[3][38]=
{                                                     // 显示 利尔达
	0x00,0x10,0x92,0x92,0xD2,0x72,0xFE,0xFB,0x53,0x93,0x90,0x00,0xFC,0xFC,0x00,0x07,0xFF,0xC2,0x00,
	0x03,0x03,0x03,0x01,0x00,0x00,0x1F,0x0F,0x00,0x00,0x00,0x08,0x08,0x18,0x18,0x0C,0x0F,0x07,0x00,
	
	0x00,0x10,0x10,0x18,0x08,0x8C,0xC7,0x47,0x04,0xFC,0xFC,0x04,0x44,0xC4,0x84,0x0C,0x7C,0x00,0x00,
	0x04,0x04,0x06,0x03,0x03,0x01,0x0C,0x08,0x18,0x1F,0x0F,0x00,0x00,0x00,0x01,0x07,0x0E,0x0E,0x04,
	
	0x00,0x30,0x16,0x16,0x76,0xB4,0x08,0x08,0x0C,0x8C,0xCC,0x7F,0x3F,0x44,0xC4,0x84,0x04,0x00,0x00,
	0x06,0x02,0x02,0x02,0x03,0x03,0x02,0x03,0x07,0x05,0x04,0x04,0x0C,0x0C,0x0C,0x1D,0x1F,0x0C,0x0C,
};

const BYTE LSD_ICON[32]=
{                                                     // 显示 LSD 图标
	0xE0,0xF0,0xFC,0xFE,0x00,0x9F,0x3F,0x71,0xE7,0xCF,0x00,0xFE,0x0C,0x1C,0xF0,0xE0,
	0x07,0x0F,0x3F,0x3F,0x70,0xF7,0xF7,0xF4,0xF7,0xF7,0x00,0x7F,0x38,0x38,0x0F,0x07,
};
//***************************************************************************************************
//***************************************************************************************************
//***************************************************************************************************
static BYTE num;
static BYTE bt_num;
//***************************************************************************************************
//***************************************************************************************************
//***************************************************************************************************

void port_ini( void )
{
	P3DIR = 0xFF;
	P3OUT = 0x00;
	
	P2DIR  = 0xFF;
	P2OUT  = P2_3_CS1 | P2_3_CS2 | P2_3_RST;
	P2OUT &=~P2_3_RST;
	_NOP();
	_NOP();
	P2OUT |= P2_2_EN;
	_NOP();
	_NOP();
	P2OUT &=~P2_2_EN;
	_NOP();
	_NOP();
	P2OUT |= P2_3_RST;
	_NOP();
	_NOP();	
}

void write_command( BYTE nByte )
{
	P3DIR = 0xFF;
	P2OUT |= P2_3_CS1+P2_3_CS2;
	P2OUT &=~(P2_0_RS+P2_1_RW);
	P3OUT = nByte;
	P2OUT |= P2_2_EN;
	P2OUT &=~P2_2_EN;
}

void write_char( BYTE nByte, BYTE CS1, BYTE CS2 )
{
	P3DIR = 0xFF;
	
	if(CS1) P2OUT |= P2_3_CS1;
	else P2OUT &=~P2_3_CS1;
	
	if(CS2) P2OUT |= P2_3_CS2;
	else P2OUT &=~P2_3_CS2;
	
	P2OUT |= P2_0_RS;
	P2OUT &=~P2_1_RW;
	
	P3OUT  = nByte;
	P2OUT |= P2_2_EN;
	P2OUT &=~P2_2_EN;
}
void clear_lcd( void )
{
	BYTE i,j;
	for(i=0;i<8;i++)
	{
		write_command(i|0xB8);
		write_command(0x40);
		for(j=0;j<128;j++)
		{
			if(j<=63) write_char(0,1,0);
			else write_char(0,0,1);
			_NOP();
		}
	}
	
}
void display_hz( BYTE *chr, BYTE nRow, BYTE nCol )
{
	BYTE i,tmpCol;
	
	write_command(0xB8|nRow);
	tmpCol=nCol;
	for(i=0;i<19;i++)
	{
		if(tmpCol<=63)
		{
			write_command(0x40|tmpCol);
			write_char(chr[i],1,0);
		}
		else
		{
			write_command(0x40|(tmpCol-64));
			write_char(chr[i],0,1);
		}
		tmpCol++;
	}
	
	write_command(0xB8|nRow+1);
	tmpCol=nCol;
	for(i=0;i<19;i++)
	{
		if(tmpCol<=63)
		{
			write_command(0x40|tmpCol);
			write_char(chr[i+19],1,0);
		}
		else
		{
			write_command(0x40|(tmpCol-64));
			write_char(chr[i+19],0,1);
		}
		tmpCol++;
	}
}
void display_16_16_icon( BYTE *chr, BYTE nRow, BYTE nCol )
{
	BYTE i,tmpCol;
	
	write_command(0xB8|nRow);
	tmpCol=nCol;
	for(i=0;i<16;i++)
	{
		if(tmpCol<=63)
		{
			write_command(0x40|tmpCol);
			write_char(chr[i],1,0);
		}
		else
		{
			write_command(0x40|(tmpCol-64));
			write_char(chr[i],0,1);
		}
		tmpCol++;
	}
	
	write_command(0xB8|nRow+1);
	tmpCol=nCol;
	for(i=0;i<16;i++)
	{
		if(tmpCol<=63)
		{
			write_command(0x40|tmpCol);
			write_char(chr[i+16],1,0);
		}
		else
		{
			write_command(0x40|(tmpCol-64));
			write_char(chr[i+16],0,1);
		}
		tmpCol++;
	}
}
void display_char( BYTE *chr, BYTE nRow, BYTE nCol )
{
	BYTE i,tmpCol;
	
	write_command(0xB8|nRow);
	tmpCol=nCol;
	for(i=0;i<5;i++)
	{
		if(tmpCol<=63)
		{
			write_command(0x40|tmpCol);
			write_char(chr[i],1,0);
		}
		else
		{
			write_command(0x40|(tmpCol-64));
			write_char(chr[i],0,1);
		}
		tmpCol++;
	}
}
//***************************************************************************************************
//***************************************************************************************************
//***************************************************************************************************
void main(void)
{
	BYTE hAddr;
	
	WDTCTL = WDTPW + WDTHOLD;				// Stop watchdog timer
	
	FLL_CTL0 |= XCAP14PF;
	
	
	port_ini();
	num=0;
        	
	write_command(0xC0);
	write_command(0x3F);
	clear_lcd();
	
	//display_16_16_icon((BYTE *)&LSD_ICON[0],1,5);           // 显示 LSD图标
	display_hz((BYTE *)&Nianyueri[0][0],0,10);              //显示 年
	display_hz((BYTE *)&Nianyueri[1][0],0,50);              //显示 月
	display_hz((BYTE *)&Nianyueri[2][0],0,90);              //显示 日
	display_hz((BYTE *)&Nianyueri[3][0],3,10);              //显示 星
	display_hz((BYTE *)&Nianyueri[4][0],3,30);              //显示 期
	display_hz((BYTE *)&Nianyueri[5][0],6,10);              //显示 时
	display_hz((BYTE *)&Nianyueri[6][0],6,30);              //显示 间
	
	
	//display_hz((BYTE *)&Lierda_13_19[0][0],3,10);           // 显示 利
	//display_hz((BYTE *)&Lierda_13_19[1][0],3,50);           // 显示 尔
	//display_hz((BYTE *)&Lierda_13_19[2][0],3,90);           // 显示 达
	
	/*display_char((BYTE *)&CHAR_T[0],6,16);                  // 显示 T
	display_char((BYTE *)&CHAR_E[0],6,22);                  // 显示 E
	display_char((BYTE *)&CHAR_L[0],6,28);                  // 显示 L
	hAddr=34;
	display_char((BYTE *)&Symbols[0][0],6,hAddr);           // 显示 0
	display_char((BYTE *)&CHAR_0[0],6,hAddr+6);             // 显示 5
	display_char((BYTE *)&CHAR_5[0],6,hAddr+12);            // 显示 7
	display_char((BYTE *)&CHAR_7[0],6,hAddr+18);            // 显示 1
	display_char((BYTE *)&CHAR_1[0],6,hAddr+24);            // 显示
	display_char((BYTE *)&Symbols[1][0],6,hAddr+30);        // 显示 -
	display_char((BYTE *)&CHAR_8[0],6,hAddr+36);            // 显示 8
	display_char((BYTE *)&CHAR_8[0],6,hAddr+42);            // 显示 8
	display_char((BYTE *)&CHAR_8[0],6,hAddr+48);            // 显示 8
	display_char((BYTE *)&CHAR_0[0],6,hAddr+54);            // 显示 0
	display_char((BYTE *)&CHAR_0[0],6,hAddr+60);            // 显示 0
	display_char((BYTE *)&CHAR_0[0],6,hAddr+66);            // 显示 0
	display_char((BYTE *)&CHAR_0[0],6,hAddr+72);            // 显示 0
	display_char((BYTE *)&CHAR_0[0],6,hAddr+78);            // 显示 0
	*/
//	WDTCTL=WDTPW+WDT_ARST_1000;
	_EINT();								// Enable interrupts

	while(1)
	{
		
         _BIC_SR(LPM3);
		_NOP();
		_NOP();
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -