
-
UID:1025142
-
- 注册时间2011-12-18
- 最后登录2019-07-30
- 在线时间298小时
-
-
访问TA的空间加好友用道具
|
源码: 为什么源码无法显示??? - #include <msp430.h>
- /*
- * VCC 电源
- * GND 地
- *
- * P1.5 CLK SPI时钟
- * P1.6 Din 数据输出
- *
- * P2.0 BL 背光控制
- * P2.1 DC 数据/控制
- * P2.2 CE 片选信号
- * P2.3 RST 复位信号
- */
- #define BL BIT0
- #define DC BIT1
- #define CE BIT2
- #define RST BIT3
- #define MOSI BIT6
- #define SCLK BIT5
- #define YEAR Time[0]
- #define MONTH Time[1]
- #define DATE Time[2]
- #define HOUR Time[3]
- #define MINUTE Time[4]
- #define SECOND Time[5]
- unsigned char Time[7] = {13, 3, 17, 13, 25, 45}; //时钟存储器
- unsigned char LCD_BL = 120;//倒计时120秒关背光
- unsigned char LCD_DS = 60;//倒计时60秒关显示
- void LCD_Write_Byte(unsigned char dat, unsigned char command)
- {
- P2OUT &= ~CE;
- if(!command)
- {
- P2OUT &= ~DC;
- }
- else
- {
- P2OUT |= DC;
- }
- USISRL = dat;
- USICNT = 0x08;
- _BIS_SR(LPM3_bits + GIE);
- P2OUT |= CE;
- }
- void LCD_Set_XY(unsigned char X, unsigned char Y)
- {
- LCD_Write_Byte(0x40 | Y, 0);
- LCD_Write_Byte(0x80 | X, 0);
- }
- void LCD_Write_Char(unsigned char c)
- {
- c -= 32;
- switch(c)
- {
- case 0: //space
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 1: //!
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x2f, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 2:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x07, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x07, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 3:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x7f, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x7f, 1);
- LCD_Write_Byte(0x14, 1);
- }
- break;
- case 4:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x24, 1);
- LCD_Write_Byte(0x2a, 1);
- LCD_Write_Byte(0x7f, 1);
- LCD_Write_Byte(0x2a, 1);
- LCD_Write_Byte(0x12, 1);
- }
- break;
- case 5:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x62, 1);
- LCD_Write_Byte(0x64, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x13, 1);
- LCD_Write_Byte(0x23, 1);
- }
- break;
- case 6:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x36, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x55, 1);
- LCD_Write_Byte(0x22, 1);
- LCD_Write_Byte(0x50, 1);
- }
- break;
- case 7:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x05, 1);
- LCD_Write_Byte(0x03, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 8:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x1c, 1);
- LCD_Write_Byte(0x22, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 9:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x22, 1);
- LCD_Write_Byte(0x1c, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 10:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x3E, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x14, 1);
- }
- break;
- case 11:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x3E, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- }
- break;
- case 12:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0xA0, 1);
- LCD_Write_Byte(0x60, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 13:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- }
- break;
- case 14:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x60, 1);
- LCD_Write_Byte(0x60, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 15:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x10, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x02, 1);
- }
- break;
- case 16: //数字 0
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3E, 1);
- LCD_Write_Byte(0x51, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x45, 1);
- LCD_Write_Byte(0x3E, 1);
- }
- break;
- case 17:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x42, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 18:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x42, 1);
- LCD_Write_Byte(0x61, 1);
- LCD_Write_Byte(0x51, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x46, 1);
- }
- break;
- case 19:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x21, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x45, 1);
- LCD_Write_Byte(0x4B, 1);
- LCD_Write_Byte(0x31, 1);
- }
- break;
- case 20:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x18, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x12, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x10, 1);
- }
- break;
- case 21:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x27, 1);
- LCD_Write_Byte(0x45, 1);
- LCD_Write_Byte(0x45, 1);
- LCD_Write_Byte(0x45, 1);
- LCD_Write_Byte(0x39, 1);
- }
- break;
- case 22:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3C, 1);
- LCD_Write_Byte(0x4A, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x30, 1);
- }
- break;
- case 23:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x71, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x05, 1);
- LCD_Write_Byte(0x03, 1);
- }
- break;
- case 24:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x36, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x36, 1);
- }
- break;
- case 25:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x06, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x29, 1);
- LCD_Write_Byte(0x1E, 1);
- }
- break;
- case 26:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x36, 1);
- LCD_Write_Byte(0x36, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 27:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x56, 1);
- LCD_Write_Byte(0x36, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- }
- case 28:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x22, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 29:
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- }
- break;
- case 30:
- //=
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x22, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x08, 1);
- }
- break;
- case 31:
- //>
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x02, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x51, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x06, 1);
- }
- break;
- case 32:
- //?
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x32, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x59, 1);
- LCD_Write_Byte(0x51, 1);
- LCD_Write_Byte(0x3E, 1);
- }
- break;
- case 33:
- //@
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7C, 1);
- LCD_Write_Byte(0x12, 1);
- LCD_Write_Byte(0x11, 1);
- LCD_Write_Byte(0x12, 1);
- LCD_Write_Byte(0x7C, 1);
- }
- break;
- case 34:
- //A
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x36, 1);
- }
- break;
- case 35:
- //B
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3E, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x22, 1);
- }
- break;
- case 36:
- //C
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x22, 1);
- LCD_Write_Byte(0x1C, 1);
- }
- break;
- case 37:
- //D
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x41, 1);
- }
- break;
- case 38:
- //E
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x01, 1);
- }
- break;
- case 39:
- //F
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3E, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x7A, 1);
- }
- break;
- case 40:
- //G
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x7F, 1);
- }
- break;
- case 41:
- //H
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 42:
- //I
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x3F, 1);
- LCD_Write_Byte(0x01, 1);
- }
- break;
- case 43:
- //J
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x22, 1);
- LCD_Write_Byte(0x41, 1);
- }
- break;
- case 44:
- //K
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- }
- break;
- case 45:
- //L
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x02, 1);
- LCD_Write_Byte(0x0C, 1);
- LCD_Write_Byte(0x02, 1);
- LCD_Write_Byte(0x7F, 1);
- }
- break;
- case 46:
- //M
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x10, 1);
- LCD_Write_Byte(0x7F, 1);
- }
- break;
- case 47:
- //N
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3E, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x3E, 1);
- }
- break;
- case 48:
- //O
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x06, 1);
- }
- break;
- case 49:
- //P
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3E, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x51, 1);
- LCD_Write_Byte(0x21, 1);
- LCD_Write_Byte(0x5E, 1);
- }
- break;
- case 50:
- //Q
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x19, 1);
- LCD_Write_Byte(0x29, 1);
- LCD_Write_Byte(0x46, 1);
- }
- break;
- case 51:
- //R
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x46, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x31, 1);
- }
- break;
- case 52:
- //S
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x01, 1);
- }
- break;
- case 53:
- //T
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3F, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x3F, 1);
- }
- break;
- case 54:
- //U
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x1F, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x1F, 1);
- }
- break;
- case 55:
- //V
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3F, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x38, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x3F, 1);
- }
- break;
- case 56:
- //W
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x63, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x63, 1);
- }
- break;
- case 57:
- //X
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x07, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x70, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x07, 1);
- }
- break;
- case 58:
- //Y
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x61, 1);
- LCD_Write_Byte(0x51, 1);
- LCD_Write_Byte(0x49, 1);
- LCD_Write_Byte(0x45, 1);
- LCD_Write_Byte(0x43, 1);
- }
- break;
- case 59:
- //Z
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 60:
- //[
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x55, 1);
- LCD_Write_Byte(0x2A, 1);
- LCD_Write_Byte(0x55, 1);
- LCD_Write_Byte(0x2A, 1);
- LCD_Write_Byte(0x55, 1);
- }
- break;
- case 61:
- //55
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 62:
- //]
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x02, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x02, 1);
- LCD_Write_Byte(0x04, 1);
- }
- break;
- case 63:
- //^
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- }
- break;
- case 64:
- //_
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x02, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 65:
- //'
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x78, 1);
- }
- break;
- case 66:
- //a
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x48, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x38, 1);
- }
- break;
- case 67:
- //b
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x38, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x20, 1);
- }
- break;
- case 68:
- //c
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x38, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x48, 1);
- LCD_Write_Byte(0x7F, 1);
- }
- break;
- case 69:
- //d
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x38, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x18, 1);
- }
- break;
- case 70:
- //e
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x7E, 1);
- LCD_Write_Byte(0x09, 1);
- LCD_Write_Byte(0x01, 1);
- LCD_Write_Byte(0x02, 1);
- }
- break;
- case 71:
- //f
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x18, 1);
- LCD_Write_Byte(0xA4, 1);
- LCD_Write_Byte(0xA4, 1);
- LCD_Write_Byte(0xA4, 1);
- LCD_Write_Byte(0x7C, 1);
- }
- break;
- case 72:
- //g
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x78, 1);
- }
- break;
- case 73:
- //h
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x7D, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 74:
- //i
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x80, 1);
- LCD_Write_Byte(0x84, 1);
- LCD_Write_Byte(0x7D, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 75:
- //j
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x10, 1);
- LCD_Write_Byte(0x28, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 76:
- //k
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x41, 1);
- LCD_Write_Byte(0x7F, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x00, 1);
- }
- break;
- case 77:
- //l
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7C, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x18, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x78, 1);
- }
- break;
- case 78:
- //m
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7C, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x78, 1);
- }
- break;
- case 79:
- //n
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x38, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x38, 1);
- }
- break;
- case 80:
- //o
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0xFC, 1);
- LCD_Write_Byte(0x24, 1);
- LCD_Write_Byte(0x24, 1);
- LCD_Write_Byte(0x24, 1);
- LCD_Write_Byte(0x18, 1);
- }
- break;
- case 81:
- //p
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x18, 1);
- LCD_Write_Byte(0x24, 1);
- LCD_Write_Byte(0x24, 1);
- LCD_Write_Byte(0x18, 1);
- LCD_Write_Byte(0xFC, 1);
- }
- break;
- case 82:
- //q
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7C, 1);
- LCD_Write_Byte(0x08, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x08, 1);
- }
- break;
- case 83:
- //r
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x48, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x20, 1);
- }
- break;
- case 84:
- //s
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x04, 1);
- LCD_Write_Byte(0x3F, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x20, 1);
- }
- break;
- case 85:
- //t
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3C, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x7C, 1);
- }
- break;
- case 86:
- //u
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x1C, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x20, 1);
- LCD_Write_Byte(0x1C, 1);
- }
- break;
- case 87:
- //v
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x3C, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x30, 1);
- LCD_Write_Byte(0x40, 1);
- LCD_Write_Byte(0x3C, 1);
- }
- break;
- case 88:
- //w
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x28, 1);
- LCD_Write_Byte(0x10, 1);
- LCD_Write_Byte(0x28, 1);
- LCD_Write_Byte(0x44, 1);
- }
- break;
- case 89:
- //x
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x1C, 1);
- LCD_Write_Byte(0xA0, 1);
- LCD_Write_Byte(0xA0, 1);
- LCD_Write_Byte(0xA0, 1);
- LCD_Write_Byte(0x7C, 1);
- }
- break;
- case 90:
- //y
- {
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x44, 1);
- LCD_Write_Byte(0x64, 1);
- LCD_Write_Byte(0x54, 1);
- LCD_Write_Byte(0x4C, 1);
- LCD_Write_Byte(0x44, 1);
- }
- break;
- case 91:
- //z
- {
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- LCD_Write_Byte(0x14, 1);
- break;
- default:
- LCD_Write_Byte(0x1f, 1);
- break;
- }
- }
- }
- void LCD_Write_English_String(unsigned char X, unsigned char Y, char *s)
- {
- LCD_Set_XY(X, Y);
- while (*s)
- {
- LCD_Write_Char(*s);
- s++;
- }
- }
- void LCD_Write_Number(unsigned char X, unsigned char Y, unsigned char s) //显示一位数字的快速重写
- {
- switch(s)
- {
- case 0:
- LCD_Write_English_String(X, Y, "0");
- break;
- case 1:
- LCD_Write_English_String(X, Y, "1");
- break;
- case 2:
- LCD_Write_English_String(X, Y, "2");
- break;
- case 3:
- LCD_Write_English_String(X, Y, "3");
- break;
- case 4:
- LCD_Write_English_String(X, Y, "4");
- break;
- case 5:
- LCD_Write_English_String(X, Y, "5");
- break;
- case 6:
- LCD_Write_English_String(X, Y, "6");
- break;
- case 7:
- LCD_Write_English_String(X, Y, "7");
- break;
- case 8:
- LCD_Write_English_String(X, Y, "8");
- break;
- case 9:
- LCD_Write_English_String(X, Y, "9");
- break;
- default:
- LCD_Write_English_String(X, Y, "-");
- break;
- }
- }
- void LCD_Clear()
- {
- int i = 0;
- for(i = 0; i < 504; i++)
- {
- LCD_Write_Byte(0x00, 1); //清屏
- }
- }
- void LCD_init(void)
- {
- P2DIR |= BL + DC + CE + RST;
- P1DIR |= MOSI + SCLK;
- P1SEL = MOSI + SCLK;
- USICTL0 |= USISWRST;
- USICTL0 = USIPE6 + USIPE5 + USIMST + USIOE + USISWRST;
- USICTL1 |= USIIE + USICKPH;
- USICKCTL = USIDIV_0 + USISSEL_1;
- USICTL0 &= ~USISWRST;
- //复位
- P2OUT &= ~RST;
- P2OUT |= RST;
- P2OUT &= ~CE;
- P2OUT |= CE;
- LCD_Write_Byte(0x21, 0); //扩展命令设置模式
- LCD_Write_Byte(0xc8, 0); //设置偏置电压
- LCD_Write_Byte(0x06, 0); //温度校正
- LCD_Write_Byte(0x13, 0); //1:48
- LCD_Write_Byte(0x20, 0); //使用基本模式
- LCD_Write_Byte(0x0c, 0);
- LCD_Write_Byte(0x80, 0);
- LCD_Clear();
- LCD_Write_Byte(0x0c, 0); //设置显示模式,正常显示
- P2OUT &= ~CE;
- /*
- USICKCTL = USIDIV_7 + USISSEL_1; //初始化完毕,LCD调为低速接口,
- */
- }
- void CLKInit()
- {
- BCSCTL2 = SELM_0 + DIVM_0 + DIVS_3;
- DCOCTL = 0x00;
- BCSCTL1 = CALBC1_1MHZ;
- DCOCTL = CALDCO_1MHZ;
- BCSCTL1 |= XT2OFF + DIVA_3;
- BCSCTL3 = XT2S_0 + LFXT1S_2 + XCAP_1;
- }
- long GetTemp()
- {
- ADC10CTL1 = INCH_10 + ADC10DIV_3;
- ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;
- ADC10CTL0 |= ENC + ADC10SC;
- __bis_SR_register(CPUOFF + GIE);
- return ADC10MEM;
- }
- void PrintTempFirstInit()
- {
- LCD_Write_English_String(0, 0, "Temp:");
- //写入单条,温度的符号.
- LCD_Set_XY(41, 0); //记住,倒着写的.
- {
- LCD_Write_Byte(0x03, 1);
- LCD_Write_Byte(0x03, 1);
- LCD_Write_Byte(0x00, 1);
- LCD_Write_Byte(0x7E, 1);
- LCD_Write_Byte(0x42, 1);
- LCD_Write_Byte(0x42, 1);
- }
- }
- void PrintTemp()
- {
- int IntDegC = 100;
- do
- {
- IntDegC = ((GetTemp() - 673) * 423) / 1024;
- }
- while(IntDegC > 100 || IntDegC < 0);
- IntDegC -= 10;
- LCD_Write_Number(29, 0, IntDegC / 10);
- LCD_Write_Number(35, 0, IntDegC % 10);
- }
- void TickInit()
- {
- TA0CCTL0 = CM_0 + CCIS_0 + OUTMOD_0 + CCIE;
- TA0CCR0 = 1499;
- /*
- * TASSEL_1 -- ACLK
- * ID_0 -- Divider - /1
- * MC_1 -- Up Mode
- */
- TA0CTL = TASSEL_1 + ID_0 + MC_1;
- }
- void CalcWeek(){
- //基姆拉尔森计算公式
- int iWeek = (DATE + 2 * MONTH + 3 * (MONTH + 1) / 5 + YEAR + YEAR / 4 - YEAR / 100 + YEAR / 400) % 7;
- LCD_Write_English_String(0, 3, " ");//清空行...
- switch(iWeek)
- {
- case 0:
- LCD_Write_English_String(0, 3, "Monday");
- break;
- case 1:
- LCD_Write_English_String(0, 3, "Tuesday");
- break;
- case 2:
- LCD_Write_English_String(0, 3, "Wednesday");
- break;
- case 3:
- LCD_Write_English_String(0, 3, "Thursday");
- break;
- case 4:
- LCD_Write_English_String(0, 3, "Friday");
- break;
- case 5:
- LCD_Write_English_String(0, 3, "Saturday");
- break;
- case 6:
- LCD_Write_English_String(0, 3, "Sunday");
- break;
- }
- }
- void ClockTick()
- {
- unsigned char Days;
- if(LCD_BL > 0){
- //如果不想屏幕关闭可以加上这一行.
- LCD_BL++;
- LCD_BL--;
- if(!LCD_BL){
- P2OUT &=~ BL;
- }
- }else{
- if(LCD_DS >0 ){
- LCD_DS--;
- if(!LCD_DS){
- P2OUT &= ~RST;
- }
- }else{
- return;
- }
- }
- SECOND++;
- LCD_Write_Number(48, 2, SECOND / 10);
- LCD_Write_Number(54, 2, SECOND % 10);
- if(SECOND >= 60)
- {
- MINUTE++;
- SECOND = 0;
- LCD_Write_Number(30, 2, MINUTE / 10);
- LCD_Write_Number(36, 2, MINUTE % 10);
- }
- if(MINUTE >= 60)
- {
- HOUR++;
- MINUTE = 0;
- LCD_Write_Number(12, 2, HOUR / 10);
- LCD_Write_Number(18, 2, HOUR % 10);
- }
- if(HOUR >= 24)
- {
- DATE++;
- HOUR = 0;
- LCD_Write_Number(60, 1, DATE / 10);
- LCD_Write_Number(66, 1, DATE % 10);
- CalcWeek();
- }
- //处理闰年2月
- if(MONTH == 2)
- {
- if(!(YEAR % 4))
- {
- Days = 29;
- }
- else
- {
- Days = 28;
- }
- if(!(YEAR % 400))
- {
- Days = 28;
- }
- }
- else
- {
- switch(MONTH)
- {
- case 1:
- Days = 31;
- break;
- case 3:
- Days = 31;
- break;
- case 4:
- Days = 30;
- break;
- case 5:
- Days = 31;
- break;
- case 6:
- Days = 30;
- break;
- case 7:
- Days = 31;
- break;
- case 8:
- Days = 31;
- break;
- case 9:
- Days = 30;
- break;
- case 10:
- Days = 31;
- break;
- case 11:
- Days = 30;
- break;
- case 12:
- Days = 31;
- break;
- }
- }
- if(DATE > Days)
- {
- MONTH++;
- DATE = 1;
- LCD_Write_Number(42, 1, MONTH / 10);
- LCD_Write_Number(48, 1, MONTH % 10);
- }
- if(MONTH > 12)
- {
- YEAR++;
- MONTH = 1;
- LCD_Write_Number(24, 1, YEAR / 10);
- LCD_Write_Number(30, 1, YEAR % 10);
- }
- if(YEAR >= 100)
- {
- YEAR = 0; //100年是上限
- }
- }
- void ClockInit(){
- LCD_Write_English_String(0, 1, "D:");
- LCD_Write_English_String(12, 1, "20");
- LCD_Write_Number(24, 1, YEAR / 10);
- LCD_Write_Number(30, 1, YEAR % 10);
- LCD_Write_English_String(36, 1, "-");
- LCD_Write_Number(42, 1, MONTH / 10);
- LCD_Write_Number(48, 1, MONTH % 10);
- LCD_Write_English_String(54, 1, "-");
- LCD_Write_Number(60, 1, DATE / 10);
- LCD_Write_Number(66, 1, DATE % 10);
- LCD_Write_English_String(0, 2, "T:");
- LCD_Write_Number(12, 2, HOUR / 10);
- LCD_Write_Number(18, 2, HOUR % 10);
- LCD_Write_English_String(24, 2, ":");
- LCD_Write_Number(30, 2, MINUTE / 10);
- LCD_Write_Number(36, 2, MINUTE % 10);
- LCD_Write_English_String(42, 2, ":");
- LCD_Write_Number(48, 2, SECOND / 10);
- LCD_Write_Number(54, 2, SECOND % 10);
- CalcWeek();
- }
- void TickOnTimer()
- {
- PrintTemp();
- ClockTick();
- }
- void GPIOInit(){
- P1IE = BIT3;
- P2OUT |= BL;
- }
- void NoTimerInit(){
- WDTCTL = WDTPW | WDTHOLD;
- CLKInit();
- LCD_init();
- PrintTempFirstInit();
- PrintTemp();
- ClockInit();
- ClockTick();
- GPIOInit();
- //心跳最后初始化
- TickInit();
- }
- void main(void)
- {
- NoTimerInit();
- P2OUT |= BL;
- for(;;)
- {
- _BIS_SR(LPM3_bits + GIE);
- TickOnTimer();
- //部分擦除
- }
- }
- #pragma vector=USI_VECTOR
- __interrupt void USI_ISR_HOOK(void)
- {
- if (USICTL1 & USIIFG)
- {
- USICTL1 &= ~USIIFG;
- _bic_SR_register_on_exit(LPM3_bits + GIE);
- }
- if (USICTL1 & USISTTIFG)
- {
- //无动作
- }
- }
- #pragma vector=ADC10_VECTOR
- __interrupt void ADC10_ISR_HOOK(void)
- {
- __bic_SR_register_on_exit(CPUOFF);
- }
- //定时器是单源中断
- #pragma vector=TIMER0_A0_VECTOR
- __interrupt void TIMER0_A0_ISR_HOOK(void)
- {
- _bic_SR_register_on_exit(LPM3_bits + GIE);
- }
- #pragma vector=PORT1_VECTOR
- __interrupt void PORT1_ISR_HOOK(void)
- {
- if((P1IFG&BIT3) == BIT3)
- {
- LCD_BL += 30;
- LCD_DS = 30;
- NoTimerInit();
- }else{
- LCD_DS = 2;
- }
- }
因为内存实在小的恐怖,所以不能用const写数字的模了。 这个不含大字版本,大字版本在我微博里面有得下载,而且好像有点BUG。 加点专家和M???
|