切换到宽版
  • 3167阅读
  • 6回复

[MSP]MSP430G做时钟 [复制链接]

上一主题 下一主题
离线cl17726
 

发帖
2318
M币
4098
专家
3
粉丝
36
只看楼主 倒序阅读 我要置顶 楼主  发表于: 2013-03-17
源码: 为什么源码无法显示???
  1. #include <msp430.h>
  2. /*
  3. * VCC 电源
  4. * GND 地
  5. *
  6. * P1.5 CLK SPI时钟
  7. * P1.6 Din 数据输出
  8. *
  9. * P2.0 BL 背光控制
  10. * P2.1 DC 数据/控制
  11. * P2.2 CE 片选信号
  12. * P2.3 RST 复位信号
  13. */
  14. #define BL BIT0
  15. #define DC BIT1
  16. #define CE BIT2
  17. #define RST BIT3
  18. #define MOSI BIT6
  19. #define SCLK BIT5
  20. #define YEAR   Time[0]
  21. #define MONTH  Time[1]
  22. #define DATE   Time[2]
  23. #define HOUR   Time[3]
  24. #define MINUTE Time[4]
  25. #define SECOND Time[5]
  26. unsigned char Time[7] = {13, 3, 17, 13, 25, 45}; //时钟存储器
  27. unsigned char LCD_BL = 120;//倒计时120秒关背光
  28. unsigned char LCD_DS = 60;//倒计时60秒关显示
  29. void LCD_Write_Byte(unsigned char dat, unsigned char command)
  30. {
  31.     P2OUT &= ~CE;
  32.     if(!command)
  33.     {
  34.         P2OUT &= ~DC;
  35.     }
  36.     else
  37.     {
  38.         P2OUT |= DC;
  39.     }
  40.     USISRL = dat;
  41.     USICNT = 0x08;
  42.     _BIS_SR(LPM3_bits + GIE);
  43.     P2OUT |= CE;
  44. }
  45. void LCD_Set_XY(unsigned char X, unsigned char Y)
  46. {
  47.     LCD_Write_Byte(0x40 | Y, 0);
  48.     LCD_Write_Byte(0x80 | X, 0);
  49. }
  50. void LCD_Write_Char(unsigned char c)
  51. {
  52.     c -= 32;
  53.     switch(c)
  54.     {
  55.     case 0: //space
  56.     {
  57.         LCD_Write_Byte(0x00, 1);
  58.         LCD_Write_Byte(0x00, 1);
  59.         LCD_Write_Byte(0x00, 1);
  60.         LCD_Write_Byte(0x00, 1);
  61.         LCD_Write_Byte(0x00, 1);
  62.         LCD_Write_Byte(0x00, 1);
  63.     }
  64.     break;
  65.     case 1: //!
  66.     {
  67.         LCD_Write_Byte(0x00, 1);
  68.         LCD_Write_Byte(0x00, 1);
  69.         LCD_Write_Byte(0x00, 1);
  70.         LCD_Write_Byte(0x2f, 1);
  71.         LCD_Write_Byte(0x00, 1);
  72.         LCD_Write_Byte(0x00, 1);
  73.     }
  74.     break;
  75.     case 2:
  76.     {
  77.         LCD_Write_Byte(0x00, 1);
  78.         LCD_Write_Byte(0x00, 1);
  79.         LCD_Write_Byte(0x07, 1);
  80.         LCD_Write_Byte(0x00, 1);
  81.         LCD_Write_Byte(0x07, 1);
  82.         LCD_Write_Byte(0x00, 1);
  83.     }
  84.     break;
  85.     case 3:
  86.     {
  87.         LCD_Write_Byte(0x00, 1);
  88.         LCD_Write_Byte(0x14, 1);
  89.         LCD_Write_Byte(0x7f, 1);
  90.         LCD_Write_Byte(0x14, 1);
  91.         LCD_Write_Byte(0x7f, 1);
  92.         LCD_Write_Byte(0x14, 1);
  93.     }
  94.     break;
  95.     case 4:
  96.     {
  97.         LCD_Write_Byte(0x00, 1);
  98.         LCD_Write_Byte(0x24, 1);
  99.         LCD_Write_Byte(0x2a, 1);
  100.         LCD_Write_Byte(0x7f, 1);
  101.         LCD_Write_Byte(0x2a, 1);
  102.         LCD_Write_Byte(0x12, 1);
  103.     }
  104.     break;
  105.     case 5:
  106.     {
  107.         LCD_Write_Byte(0x00, 1);
  108.         LCD_Write_Byte(0x62, 1);
  109.         LCD_Write_Byte(0x64, 1);
  110.         LCD_Write_Byte(0x08, 1);
  111.         LCD_Write_Byte(0x13, 1);
  112.         LCD_Write_Byte(0x23, 1);
  113.     }
  114.     break;
  115.     case 6:
  116.     {
  117.         LCD_Write_Byte(0x00, 1);
  118.         LCD_Write_Byte(0x36, 1);
  119.         LCD_Write_Byte(0x49, 1);
  120.         LCD_Write_Byte(0x55, 1);
  121.         LCD_Write_Byte(0x22, 1);
  122.         LCD_Write_Byte(0x50, 1);
  123.     }
  124.     break;
  125.     case 7:
  126.     {
  127.         LCD_Write_Byte(0x00, 1);
  128.         LCD_Write_Byte(0x00, 1);
  129.         LCD_Write_Byte(0x05, 1);
  130.         LCD_Write_Byte(0x03, 1);
  131.         LCD_Write_Byte(0x00, 1);
  132.         LCD_Write_Byte(0x00, 1);
  133.     }
  134.     break;
  135.     case 8:
  136.     {
  137.         LCD_Write_Byte(0x00, 1);
  138.         LCD_Write_Byte(0x00, 1);
  139.         LCD_Write_Byte(0x1c, 1);
  140.         LCD_Write_Byte(0x22, 1);
  141.         LCD_Write_Byte(0x41, 1);
  142.         LCD_Write_Byte(0x00, 1);
  143.     }
  144.     break;
  145.     case 9:
  146.     {
  147.         LCD_Write_Byte(0x00, 1);
  148.         LCD_Write_Byte(0x00, 1);
  149.         LCD_Write_Byte(0x41, 1);
  150.         LCD_Write_Byte(0x22, 1);
  151.         LCD_Write_Byte(0x1c, 1);
  152.         LCD_Write_Byte(0x00, 1);
  153.     }
  154.     break;
  155.     case 10:
  156.     {
  157.         LCD_Write_Byte(0x00, 1);
  158.         LCD_Write_Byte(0x14, 1);
  159.         LCD_Write_Byte(0x08, 1);
  160.         LCD_Write_Byte(0x3E, 1);
  161.         LCD_Write_Byte(0x08, 1);
  162.         LCD_Write_Byte(0x14, 1);
  163.     }
  164.     break;
  165.     case 11:
  166.     {
  167.         LCD_Write_Byte(0x00, 1);
  168.         LCD_Write_Byte(0x08, 1);
  169.         LCD_Write_Byte(0x08, 1);
  170.         LCD_Write_Byte(0x3E, 1);
  171.         LCD_Write_Byte(0x08, 1);
  172.         LCD_Write_Byte(0x08, 1);
  173.     }
  174.     break;
  175.     case 12:
  176.     {
  177.         LCD_Write_Byte(0x00, 1);
  178.         LCD_Write_Byte(0x00, 1);
  179.         LCD_Write_Byte(0x00, 1);
  180.         LCD_Write_Byte(0xA0, 1);
  181.         LCD_Write_Byte(0x60, 1);
  182.         LCD_Write_Byte(0x00, 1);
  183.     }
  184.     break;
  185.     case 13:
  186.     {
  187.         LCD_Write_Byte(0x00, 1);
  188.         LCD_Write_Byte(0x08, 1);
  189.         LCD_Write_Byte(0x08, 1);
  190.         LCD_Write_Byte(0x08, 1);
  191.         LCD_Write_Byte(0x08, 1);
  192.         LCD_Write_Byte(0x08, 1);
  193.     }
  194.     break;
  195.     case 14:
  196.     {
  197.         LCD_Write_Byte(0x00, 1);
  198.         LCD_Write_Byte(0x00, 1);
  199.         LCD_Write_Byte(0x60, 1);
  200.         LCD_Write_Byte(0x60, 1);
  201.         LCD_Write_Byte(0x00, 1);
  202.         LCD_Write_Byte(0x00, 1);
  203.     }
  204.     break;
  205.     case 15:
  206.     {
  207.         LCD_Write_Byte(0x00, 1);
  208.         LCD_Write_Byte(0x20, 1);
  209.         LCD_Write_Byte(0x10, 1);
  210.         LCD_Write_Byte(0x08, 1);
  211.         LCD_Write_Byte(0x04, 1);
  212.         LCD_Write_Byte(0x02, 1);
  213.     }
  214.     break;
  215.     case 16: //数字 0
  216.     {
  217.         LCD_Write_Byte(0x00, 1);
  218.         LCD_Write_Byte(0x3E, 1);
  219.         LCD_Write_Byte(0x51, 1);
  220.         LCD_Write_Byte(0x49, 1);
  221.         LCD_Write_Byte(0x45, 1);
  222.         LCD_Write_Byte(0x3E, 1);
  223.     }
  224.     break;
  225.     case 17:
  226.     {
  227.         LCD_Write_Byte(0x00, 1);
  228.         LCD_Write_Byte(0x00, 1);
  229.         LCD_Write_Byte(0x42, 1);
  230.         LCD_Write_Byte(0x7F, 1);
  231.         LCD_Write_Byte(0x40, 1);
  232.         LCD_Write_Byte(0x00, 1);
  233.     }
  234.     break;
  235.     case 18:
  236.     {
  237.         LCD_Write_Byte(0x00, 1);
  238.         LCD_Write_Byte(0x42, 1);
  239.         LCD_Write_Byte(0x61, 1);
  240.         LCD_Write_Byte(0x51, 1);
  241.         LCD_Write_Byte(0x49, 1);
  242.         LCD_Write_Byte(0x46, 1);
  243.     }
  244.     break;
  245.     case 19:
  246.     {
  247.         LCD_Write_Byte(0x00, 1);
  248.         LCD_Write_Byte(0x21, 1);
  249.         LCD_Write_Byte(0x41, 1);
  250.         LCD_Write_Byte(0x45, 1);
  251.         LCD_Write_Byte(0x4B, 1);
  252.         LCD_Write_Byte(0x31, 1);
  253.     }
  254.     break;
  255.     case 20:
  256.     {
  257.         LCD_Write_Byte(0x00, 1);
  258.         LCD_Write_Byte(0x18, 1);
  259.         LCD_Write_Byte(0x14, 1);
  260.         LCD_Write_Byte(0x12, 1);
  261.         LCD_Write_Byte(0x7F, 1);
  262.         LCD_Write_Byte(0x10, 1);
  263.     }
  264.     break;
  265.     case 21:
  266.     {
  267.         LCD_Write_Byte(0x00, 1);
  268.         LCD_Write_Byte(0x27, 1);
  269.         LCD_Write_Byte(0x45, 1);
  270.         LCD_Write_Byte(0x45, 1);
  271.         LCD_Write_Byte(0x45, 1);
  272.         LCD_Write_Byte(0x39, 1);
  273.     }
  274.     break;
  275.     case 22:
  276.     {
  277.         LCD_Write_Byte(0x00, 1);
  278.         LCD_Write_Byte(0x3C, 1);
  279.         LCD_Write_Byte(0x4A, 1);
  280.         LCD_Write_Byte(0x49, 1);
  281.         LCD_Write_Byte(0x49, 1);
  282.         LCD_Write_Byte(0x30, 1);
  283.     }
  284.     break;
  285.     case 23:
  286.     {
  287.         LCD_Write_Byte(0x00, 1);
  288.         LCD_Write_Byte(0x01, 1);
  289.         LCD_Write_Byte(0x71, 1);
  290.         LCD_Write_Byte(0x09, 1);
  291.         LCD_Write_Byte(0x05, 1);
  292.         LCD_Write_Byte(0x03, 1);
  293.     }
  294.     break;
  295.     case 24:
  296.     {
  297.         LCD_Write_Byte(0x00, 1);
  298.         LCD_Write_Byte(0x36, 1);
  299.         LCD_Write_Byte(0x49, 1);
  300.         LCD_Write_Byte(0x49, 1);
  301.         LCD_Write_Byte(0x49, 1);
  302.         LCD_Write_Byte(0x36, 1);
  303.     }
  304.     break;
  305.     case 25:
  306.     {
  307.         LCD_Write_Byte(0x00, 1);
  308.         LCD_Write_Byte(0x06, 1);
  309.         LCD_Write_Byte(0x49, 1);
  310.         LCD_Write_Byte(0x49, 1);
  311.         LCD_Write_Byte(0x29, 1);
  312.         LCD_Write_Byte(0x1E, 1);
  313.     }
  314.     break;
  315.     case 26:
  316.     {
  317.         LCD_Write_Byte(0x00, 1);
  318.         LCD_Write_Byte(0x00, 1);
  319.         LCD_Write_Byte(0x36, 1);
  320.         LCD_Write_Byte(0x36, 1);
  321.         LCD_Write_Byte(0x00, 1);
  322.         LCD_Write_Byte(0x00, 1);
  323.     }
  324.     break;
  325.     case 27:
  326.     {
  327.         LCD_Write_Byte(0x00, 1);
  328.         LCD_Write_Byte(0x00, 1);
  329.         LCD_Write_Byte(0x56, 1);
  330.         LCD_Write_Byte(0x36, 1);
  331.         LCD_Write_Byte(0x00, 1);
  332.         LCD_Write_Byte(0x00, 1);
  333.     }
  334.     case 28:
  335.     {
  336.         LCD_Write_Byte(0x00, 1);
  337.         LCD_Write_Byte(0x08, 1);
  338.         LCD_Write_Byte(0x14, 1);
  339.         LCD_Write_Byte(0x22, 1);
  340.         LCD_Write_Byte(0x41, 1);
  341.         LCD_Write_Byte(0x00, 1);
  342.     }
  343.     break;
  344.     case 29:
  345.     {
  346.         LCD_Write_Byte(0x00, 1);
  347.         LCD_Write_Byte(0x14, 1);
  348.         LCD_Write_Byte(0x14, 1);
  349.         LCD_Write_Byte(0x14, 1);
  350.         LCD_Write_Byte(0x14, 1);
  351.         LCD_Write_Byte(0x14, 1);
  352.     }
  353.     break;
  354.     case 30:
  355.         //=
  356.     {
  357.         LCD_Write_Byte(0x00, 1);
  358.         LCD_Write_Byte(0x00, 1);
  359.         LCD_Write_Byte(0x41, 1);
  360.         LCD_Write_Byte(0x22, 1);
  361.         LCD_Write_Byte(0x14, 1);
  362.         LCD_Write_Byte(0x08, 1);
  363.     }
  364.     break;
  365.     case 31:
  366.         //>
  367.     {
  368.         LCD_Write_Byte(0x00, 1);
  369.         LCD_Write_Byte(0x02, 1);
  370.         LCD_Write_Byte(0x01, 1);
  371.         LCD_Write_Byte(0x51, 1);
  372.         LCD_Write_Byte(0x09, 1);
  373.         LCD_Write_Byte(0x06, 1);
  374.     }
  375.     break;
  376.     case 32:
  377.         //?
  378.     {
  379.         LCD_Write_Byte(0x00, 1);
  380.         LCD_Write_Byte(0x32, 1);
  381.         LCD_Write_Byte(0x49, 1);
  382.         LCD_Write_Byte(0x59, 1);
  383.         LCD_Write_Byte(0x51, 1);
  384.         LCD_Write_Byte(0x3E, 1);
  385.     }
  386.     break;
  387.     case 33:
  388.         //@
  389.     {
  390.         LCD_Write_Byte(0x00, 1);
  391.         LCD_Write_Byte(0x7C, 1);
  392.         LCD_Write_Byte(0x12, 1);
  393.         LCD_Write_Byte(0x11, 1);
  394.         LCD_Write_Byte(0x12, 1);
  395.         LCD_Write_Byte(0x7C, 1);
  396.     }
  397.     break;
  398.     case 34:
  399.         //A
  400.     {
  401.         LCD_Write_Byte(0x00, 1);
  402.         LCD_Write_Byte(0x7F, 1);
  403.         LCD_Write_Byte(0x49, 1);
  404.         LCD_Write_Byte(0x49, 1);
  405.         LCD_Write_Byte(0x49, 1);
  406.         LCD_Write_Byte(0x36, 1);
  407.     }
  408.     break;
  409.     case 35:
  410.         //B
  411.     {
  412.         LCD_Write_Byte(0x00, 1);
  413.         LCD_Write_Byte(0x3E, 1);
  414.         LCD_Write_Byte(0x41, 1);
  415.         LCD_Write_Byte(0x41, 1);
  416.         LCD_Write_Byte(0x41, 1);
  417.         LCD_Write_Byte(0x22, 1);
  418.     }
  419.     break;
  420.     case 36:
  421.         //C
  422.     {
  423.         LCD_Write_Byte(0x00, 1);
  424.         LCD_Write_Byte(0x7F, 1);
  425.         LCD_Write_Byte(0x41, 1);
  426.         LCD_Write_Byte(0x41, 1);
  427.         LCD_Write_Byte(0x22, 1);
  428.         LCD_Write_Byte(0x1C, 1);
  429.     }
  430.     break;
  431.     case 37:
  432.         //D
  433.     {
  434.         LCD_Write_Byte(0x00, 1);
  435.         LCD_Write_Byte(0x7F, 1);
  436.         LCD_Write_Byte(0x49, 1);
  437.         LCD_Write_Byte(0x49, 1);
  438.         LCD_Write_Byte(0x49, 1);
  439.         LCD_Write_Byte(0x41, 1);
  440.     }
  441.     break;
  442.     case 38:
  443.         //E
  444.     {
  445.         LCD_Write_Byte(0x00, 1);
  446.         LCD_Write_Byte(0x7F, 1);
  447.         LCD_Write_Byte(0x09, 1);
  448.         LCD_Write_Byte(0x09, 1);
  449.         LCD_Write_Byte(0x09, 1);
  450.         LCD_Write_Byte(0x01, 1);
  451.     }
  452.     break;
  453.     case 39:
  454.         //F
  455.     {
  456.         LCD_Write_Byte(0x00, 1);
  457.         LCD_Write_Byte(0x3E, 1);
  458.         LCD_Write_Byte(0x41, 1);
  459.         LCD_Write_Byte(0x49, 1);
  460.         LCD_Write_Byte(0x49, 1);
  461.         LCD_Write_Byte(0x7A, 1);
  462.     }
  463.     break;
  464.     case 40:
  465.         //G
  466.     {
  467.         LCD_Write_Byte(0x00, 1);
  468.         LCD_Write_Byte(0x7F, 1);
  469.         LCD_Write_Byte(0x08, 1);
  470.         LCD_Write_Byte(0x08, 1);
  471.         LCD_Write_Byte(0x08, 1);
  472.         LCD_Write_Byte(0x7F, 1);
  473.     }
  474.     break;
  475.     case 41:
  476.         //H
  477.     {
  478.         LCD_Write_Byte(0x00, 1);
  479.         LCD_Write_Byte(0x00, 1);
  480.         LCD_Write_Byte(0x41, 1);
  481.         LCD_Write_Byte(0x7F, 1);
  482.         LCD_Write_Byte(0x41, 1);
  483.         LCD_Write_Byte(0x00, 1);
  484.     }
  485.     break;
  486.     case 42:
  487.         //I
  488.     {
  489.         LCD_Write_Byte(0x00, 1);
  490.         LCD_Write_Byte(0x20, 1);
  491.         LCD_Write_Byte(0x40, 1);
  492.         LCD_Write_Byte(0x41, 1);
  493.         LCD_Write_Byte(0x3F, 1);
  494.         LCD_Write_Byte(0x01, 1);
  495.     }
  496.     break;
  497.     case 43:
  498.         //J
  499.     {
  500.         LCD_Write_Byte(0x00, 1);
  501.         LCD_Write_Byte(0x7F, 1);
  502.         LCD_Write_Byte(0x08, 1);
  503.         LCD_Write_Byte(0x14, 1);
  504.         LCD_Write_Byte(0x22, 1);
  505.         LCD_Write_Byte(0x41, 1);
  506.     }
  507.     break;
  508.     case 44:
  509.         //K
  510.     {
  511.         LCD_Write_Byte(0x00, 1);
  512.         LCD_Write_Byte(0x7F, 1);
  513.         LCD_Write_Byte(0x40, 1);
  514.         LCD_Write_Byte(0x40, 1);
  515.         LCD_Write_Byte(0x40, 1);
  516.         LCD_Write_Byte(0x40, 1);
  517.     }
  518.     break;
  519.     case 45:
  520.         //L
  521.     {
  522.         LCD_Write_Byte(0x00, 1);
  523.         LCD_Write_Byte(0x7F, 1);
  524.         LCD_Write_Byte(0x02, 1);
  525.         LCD_Write_Byte(0x0C, 1);
  526.         LCD_Write_Byte(0x02, 1);
  527.         LCD_Write_Byte(0x7F, 1);
  528.     }
  529.     break;
  530.     case 46:
  531.         //M
  532.     {
  533.         LCD_Write_Byte(0x00, 1);
  534.         LCD_Write_Byte(0x7F, 1);
  535.         LCD_Write_Byte(0x04, 1);
  536.         LCD_Write_Byte(0x08, 1);
  537.         LCD_Write_Byte(0x10, 1);
  538.         LCD_Write_Byte(0x7F, 1);
  539.     }
  540.     break;
  541.     case 47:
  542.         //N
  543.     {
  544.         LCD_Write_Byte(0x00, 1);
  545.         LCD_Write_Byte(0x3E, 1);
  546.         LCD_Write_Byte(0x41, 1);
  547.         LCD_Write_Byte(0x41, 1);
  548.         LCD_Write_Byte(0x41, 1);
  549.         LCD_Write_Byte(0x3E, 1);
  550.     }
  551.     break;
  552.     case 48:
  553.         //O
  554.     {
  555.         LCD_Write_Byte(0x00, 1);
  556.         LCD_Write_Byte(0x7F, 1);
  557.         LCD_Write_Byte(0x09, 1);
  558.         LCD_Write_Byte(0x09, 1);
  559.         LCD_Write_Byte(0x09, 1);
  560.         LCD_Write_Byte(0x06, 1);
  561.     }
  562.     break;
  563.     case 49:
  564.         //P
  565.     {
  566.         LCD_Write_Byte(0x00, 1);
  567.         LCD_Write_Byte(0x3E, 1);
  568.         LCD_Write_Byte(0x41, 1);
  569.         LCD_Write_Byte(0x51, 1);
  570.         LCD_Write_Byte(0x21, 1);
  571.         LCD_Write_Byte(0x5E, 1);
  572.     }
  573.     break;
  574.     case 50:
  575.         //Q
  576.     {
  577.         LCD_Write_Byte(0x00, 1);
  578.         LCD_Write_Byte(0x7F, 1);
  579.         LCD_Write_Byte(0x09, 1);
  580.         LCD_Write_Byte(0x19, 1);
  581.         LCD_Write_Byte(0x29, 1);
  582.         LCD_Write_Byte(0x46, 1);
  583.     }
  584.     break;
  585.     case 51:
  586.         //R
  587.     {
  588.         LCD_Write_Byte(0x00, 1);
  589.         LCD_Write_Byte(0x46, 1);
  590.         LCD_Write_Byte(0x49, 1);
  591.         LCD_Write_Byte(0x49, 1);
  592.         LCD_Write_Byte(0x49, 1);
  593.         LCD_Write_Byte(0x31, 1);
  594.     }
  595.     break;
  596.     case 52:
  597.         //S
  598.     {
  599.         LCD_Write_Byte(0x00, 1);
  600.         LCD_Write_Byte(0x01, 1);
  601.         LCD_Write_Byte(0x01, 1);
  602.         LCD_Write_Byte(0x7F, 1);
  603.         LCD_Write_Byte(0x01, 1);
  604.         LCD_Write_Byte(0x01, 1);
  605.     }
  606.     break;
  607.     case 53:
  608.         //T
  609.     {
  610.         LCD_Write_Byte(0x00, 1);
  611.         LCD_Write_Byte(0x3F, 1);
  612.         LCD_Write_Byte(0x40, 1);
  613.         LCD_Write_Byte(0x40, 1);
  614.         LCD_Write_Byte(0x40, 1);
  615.         LCD_Write_Byte(0x3F, 1);
  616.     }
  617.     break;
  618.     case 54:
  619.         //U
  620.     {
  621.         LCD_Write_Byte(0x00, 1);
  622.         LCD_Write_Byte(0x1F, 1);
  623.         LCD_Write_Byte(0x20, 1);
  624.         LCD_Write_Byte(0x40, 1);
  625.         LCD_Write_Byte(0x20, 1);
  626.         LCD_Write_Byte(0x1F, 1);
  627.     }
  628.     break;
  629.     case 55:
  630.         //V
  631.     {
  632.         LCD_Write_Byte(0x00, 1);
  633.         LCD_Write_Byte(0x3F, 1);
  634.         LCD_Write_Byte(0x40, 1);
  635.         LCD_Write_Byte(0x38, 1);
  636.         LCD_Write_Byte(0x40, 1);
  637.         LCD_Write_Byte(0x3F, 1);
  638.     }
  639.     break;
  640.     case 56:
  641.         //W
  642.     {
  643.         LCD_Write_Byte(0x00, 1);
  644.         LCD_Write_Byte(0x63, 1);
  645.         LCD_Write_Byte(0x14, 1);
  646.         LCD_Write_Byte(0x08, 1);
  647.         LCD_Write_Byte(0x14, 1);
  648.         LCD_Write_Byte(0x63, 1);
  649.     }
  650.     break;
  651.     case 57:
  652.         //X
  653.     {
  654.         LCD_Write_Byte(0x00, 1);
  655.         LCD_Write_Byte(0x07, 1);
  656.         LCD_Write_Byte(0x08, 1);
  657.         LCD_Write_Byte(0x70, 1);
  658.         LCD_Write_Byte(0x08, 1);
  659.         LCD_Write_Byte(0x07, 1);
  660.     }
  661.     break;
  662.     case 58:
  663.         //Y
  664.     {
  665.         LCD_Write_Byte(0x00, 1);
  666.         LCD_Write_Byte(0x61, 1);
  667.         LCD_Write_Byte(0x51, 1);
  668.         LCD_Write_Byte(0x49, 1);
  669.         LCD_Write_Byte(0x45, 1);
  670.         LCD_Write_Byte(0x43, 1);
  671.     }
  672.     break;
  673.     case 59:
  674.         //Z
  675.     {
  676.         LCD_Write_Byte(0x00, 1);
  677.         LCD_Write_Byte(0x00, 1);
  678.         LCD_Write_Byte(0x7F, 1);
  679.         LCD_Write_Byte(0x41, 1);
  680.         LCD_Write_Byte(0x41, 1);
  681.         LCD_Write_Byte(0x00, 1);
  682.     }
  683.     break;
  684.     case 60:
  685.         //[
  686.     {
  687.         LCD_Write_Byte(0x00, 1);
  688.         LCD_Write_Byte(0x55, 1);
  689.         LCD_Write_Byte(0x2A, 1);
  690.         LCD_Write_Byte(0x55, 1);
  691.         LCD_Write_Byte(0x2A, 1);
  692.         LCD_Write_Byte(0x55, 1);
  693.     }
  694.     break;
  695.     case 61:
  696.         //55
  697.     {
  698.         LCD_Write_Byte(0x00, 1);
  699.         LCD_Write_Byte(0x00, 1);
  700.         LCD_Write_Byte(0x41, 1);
  701.         LCD_Write_Byte(0x41, 1);
  702.         LCD_Write_Byte(0x7F, 1);
  703.         LCD_Write_Byte(0x00, 1);
  704.     }
  705.     break;
  706.     case 62:
  707.         //]
  708.     {
  709.         LCD_Write_Byte(0x00, 1);
  710.         LCD_Write_Byte(0x04, 1);
  711.         LCD_Write_Byte(0x02, 1);
  712.         LCD_Write_Byte(0x01, 1);
  713.         LCD_Write_Byte(0x02, 1);
  714.         LCD_Write_Byte(0x04, 1);
  715.     }
  716.     break;
  717.     case 63:
  718.         //^
  719.     {
  720.         LCD_Write_Byte(0x00, 1);
  721.         LCD_Write_Byte(0x40, 1);
  722.         LCD_Write_Byte(0x40, 1);
  723.         LCD_Write_Byte(0x40, 1);
  724.         LCD_Write_Byte(0x40, 1);
  725.         LCD_Write_Byte(0x40, 1);
  726.     }
  727.     break;
  728.     case 64:
  729.         //_
  730.     {
  731.         LCD_Write_Byte(0x00, 1);
  732.         LCD_Write_Byte(0x00, 1);
  733.         LCD_Write_Byte(0x01, 1);
  734.         LCD_Write_Byte(0x02, 1);
  735.         LCD_Write_Byte(0x04, 1);
  736.         LCD_Write_Byte(0x00, 1);
  737.     }
  738.     break;
  739.     case 65:
  740.         //'
  741.     {
  742.         LCD_Write_Byte(0x00, 1);
  743.         LCD_Write_Byte(0x20, 1);
  744.         LCD_Write_Byte(0x54, 1);
  745.         LCD_Write_Byte(0x54, 1);
  746.         LCD_Write_Byte(0x54, 1);
  747.         LCD_Write_Byte(0x78, 1);
  748.     }
  749.     break;
  750.     case 66:
  751.         //a
  752.     {
  753.         LCD_Write_Byte(0x00, 1);
  754.         LCD_Write_Byte(0x7F, 1);
  755.         LCD_Write_Byte(0x48, 1);
  756.         LCD_Write_Byte(0x44, 1);
  757.         LCD_Write_Byte(0x44, 1);
  758.         LCD_Write_Byte(0x38, 1);
  759.     }
  760.     break;
  761.     case 67:
  762.         //b
  763.     {
  764.         LCD_Write_Byte(0x00, 1);
  765.         LCD_Write_Byte(0x38, 1);
  766.         LCD_Write_Byte(0x44, 1);
  767.         LCD_Write_Byte(0x44, 1);
  768.         LCD_Write_Byte(0x44, 1);
  769.         LCD_Write_Byte(0x20, 1);
  770.     }
  771.     break;
  772.     case 68:
  773.         //c
  774.     {
  775.         LCD_Write_Byte(0x00, 1);
  776.         LCD_Write_Byte(0x38, 1);
  777.         LCD_Write_Byte(0x44, 1);
  778.         LCD_Write_Byte(0x44, 1);
  779.         LCD_Write_Byte(0x48, 1);
  780.         LCD_Write_Byte(0x7F, 1);
  781.     }
  782.     break;
  783.     case 69:
  784.         //d
  785.     {
  786.         LCD_Write_Byte(0x00, 1);
  787.         LCD_Write_Byte(0x38, 1);
  788.         LCD_Write_Byte(0x54, 1);
  789.         LCD_Write_Byte(0x54, 1);
  790.         LCD_Write_Byte(0x54, 1);
  791.         LCD_Write_Byte(0x18, 1);
  792.     }
  793.     break;
  794.     case 70:
  795.         //e
  796.     {
  797.         LCD_Write_Byte(0x00, 1);
  798.         LCD_Write_Byte(0x08, 1);
  799.         LCD_Write_Byte(0x7E, 1);
  800.         LCD_Write_Byte(0x09, 1);
  801.         LCD_Write_Byte(0x01, 1);
  802.         LCD_Write_Byte(0x02, 1);
  803.     }
  804.     break;
  805.     case 71:
  806.         //f
  807.     {
  808.         LCD_Write_Byte(0x00, 1);
  809.         LCD_Write_Byte(0x18, 1);
  810.         LCD_Write_Byte(0xA4, 1);
  811.         LCD_Write_Byte(0xA4, 1);
  812.         LCD_Write_Byte(0xA4, 1);
  813.         LCD_Write_Byte(0x7C, 1);
  814.     }
  815.     break;
  816.     case 72:
  817.         //g
  818.     {
  819.         LCD_Write_Byte(0x00, 1);
  820.         LCD_Write_Byte(0x7F, 1);
  821.         LCD_Write_Byte(0x08, 1);
  822.         LCD_Write_Byte(0x04, 1);
  823.         LCD_Write_Byte(0x04, 1);
  824.         LCD_Write_Byte(0x78, 1);
  825.     }
  826.     break;
  827.     case 73:
  828.         //h
  829.     {
  830.         LCD_Write_Byte(0x00, 1);
  831.         LCD_Write_Byte(0x00, 1);
  832.         LCD_Write_Byte(0x44, 1);
  833.         LCD_Write_Byte(0x7D, 1);
  834.         LCD_Write_Byte(0x40, 1);
  835.         LCD_Write_Byte(0x00, 1);
  836.     }
  837.     break;
  838.     case 74:
  839.         //i
  840.     {
  841.         LCD_Write_Byte(0x00, 1);
  842.         LCD_Write_Byte(0x40, 1);
  843.         LCD_Write_Byte(0x80, 1);
  844.         LCD_Write_Byte(0x84, 1);
  845.         LCD_Write_Byte(0x7D, 1);
  846.         LCD_Write_Byte(0x00, 1);
  847.     }
  848.     break;
  849.     case 75:
  850.         //j
  851.     {
  852.         LCD_Write_Byte(0x00, 1);
  853.         LCD_Write_Byte(0x7F, 1);
  854.         LCD_Write_Byte(0x10, 1);
  855.         LCD_Write_Byte(0x28, 1);
  856.         LCD_Write_Byte(0x44, 1);
  857.         LCD_Write_Byte(0x00, 1);
  858.     }
  859.     break;
  860.     case 76:
  861.         //k
  862.     {
  863.         LCD_Write_Byte(0x00, 1);
  864.         LCD_Write_Byte(0x00, 1);
  865.         LCD_Write_Byte(0x41, 1);
  866.         LCD_Write_Byte(0x7F, 1);
  867.         LCD_Write_Byte(0x40, 1);
  868.         LCD_Write_Byte(0x00, 1);
  869.     }
  870.     break;
  871.     case 77:
  872.         //l
  873.     {
  874.         LCD_Write_Byte(0x00, 1);
  875.         LCD_Write_Byte(0x7C, 1);
  876.         LCD_Write_Byte(0x04, 1);
  877.         LCD_Write_Byte(0x18, 1);
  878.         LCD_Write_Byte(0x04, 1);
  879.         LCD_Write_Byte(0x78, 1);
  880.     }
  881.     break;
  882.     case 78:
  883.         //m
  884.     {
  885.         LCD_Write_Byte(0x00, 1);
  886.         LCD_Write_Byte(0x7C, 1);
  887.         LCD_Write_Byte(0x08, 1);
  888.         LCD_Write_Byte(0x04, 1);
  889.         LCD_Write_Byte(0x04, 1);
  890.         LCD_Write_Byte(0x78, 1);
  891.     }
  892.     break;
  893.     case 79:
  894.         //n
  895.     {
  896.         LCD_Write_Byte(0x00, 1);
  897.         LCD_Write_Byte(0x38, 1);
  898.         LCD_Write_Byte(0x44, 1);
  899.         LCD_Write_Byte(0x44, 1);
  900.         LCD_Write_Byte(0x44, 1);
  901.         LCD_Write_Byte(0x38, 1);
  902.     }
  903.     break;
  904.     case 80:
  905.         //o
  906.     {
  907.         LCD_Write_Byte(0x00, 1);
  908.         LCD_Write_Byte(0xFC, 1);
  909.         LCD_Write_Byte(0x24, 1);
  910.         LCD_Write_Byte(0x24, 1);
  911.         LCD_Write_Byte(0x24, 1);
  912.         LCD_Write_Byte(0x18, 1);
  913.     }
  914.     break;
  915.     case 81:
  916.         //p
  917.     {
  918.         LCD_Write_Byte(0x00, 1);
  919.         LCD_Write_Byte(0x18, 1);
  920.         LCD_Write_Byte(0x24, 1);
  921.         LCD_Write_Byte(0x24, 1);
  922.         LCD_Write_Byte(0x18, 1);
  923.         LCD_Write_Byte(0xFC, 1);
  924.     }
  925.     break;
  926.     case 82:
  927.         //q
  928.     {
  929.         LCD_Write_Byte(0x00, 1);
  930.         LCD_Write_Byte(0x7C, 1);
  931.         LCD_Write_Byte(0x08, 1);
  932.         LCD_Write_Byte(0x04, 1);
  933.         LCD_Write_Byte(0x04, 1);
  934.         LCD_Write_Byte(0x08, 1);
  935.     }
  936.     break;
  937.     case 83:
  938.         //r
  939.     {
  940.         LCD_Write_Byte(0x00, 1);
  941.         LCD_Write_Byte(0x48, 1);
  942.         LCD_Write_Byte(0x54, 1);
  943.         LCD_Write_Byte(0x54, 1);
  944.         LCD_Write_Byte(0x54, 1);
  945.         LCD_Write_Byte(0x20, 1);
  946.     }
  947.     break;
  948.     case 84:
  949.         //s
  950.     {
  951.         LCD_Write_Byte(0x00, 1);
  952.         LCD_Write_Byte(0x04, 1);
  953.         LCD_Write_Byte(0x3F, 1);
  954.         LCD_Write_Byte(0x44, 1);
  955.         LCD_Write_Byte(0x40, 1);
  956.         LCD_Write_Byte(0x20, 1);
  957.     }
  958.     break;
  959.     case 85:
  960.         //t
  961.     {
  962.         LCD_Write_Byte(0x00, 1);
  963.         LCD_Write_Byte(0x3C, 1);
  964.         LCD_Write_Byte(0x40, 1);
  965.         LCD_Write_Byte(0x40, 1);
  966.         LCD_Write_Byte(0x20, 1);
  967.         LCD_Write_Byte(0x7C, 1);
  968.     }
  969.     break;
  970.     case 86:
  971.         //u
  972.     {
  973.         LCD_Write_Byte(0x00, 1);
  974.         LCD_Write_Byte(0x1C, 1);
  975.         LCD_Write_Byte(0x20, 1);
  976.         LCD_Write_Byte(0x40, 1);
  977.         LCD_Write_Byte(0x20, 1);
  978.         LCD_Write_Byte(0x1C, 1);
  979.     }
  980.     break;
  981.     case 87:
  982.         //v
  983.     {
  984.         LCD_Write_Byte(0x00, 1);
  985.         LCD_Write_Byte(0x3C, 1);
  986.         LCD_Write_Byte(0x40, 1);
  987.         LCD_Write_Byte(0x30, 1);
  988.         LCD_Write_Byte(0x40, 1);
  989.         LCD_Write_Byte(0x3C, 1);
  990.     }
  991.     break;
  992.     case 88:
  993.         //w
  994.     {
  995.         LCD_Write_Byte(0x00, 1);
  996.         LCD_Write_Byte(0x44, 1);
  997.         LCD_Write_Byte(0x28, 1);
  998.         LCD_Write_Byte(0x10, 1);
  999.         LCD_Write_Byte(0x28, 1);
  1000.         LCD_Write_Byte(0x44, 1);
  1001.     }
  1002.     break;
  1003.     case 89:
  1004.         //x
  1005.     {
  1006.         LCD_Write_Byte(0x00, 1);
  1007.         LCD_Write_Byte(0x1C, 1);
  1008.         LCD_Write_Byte(0xA0, 1);
  1009.         LCD_Write_Byte(0xA0, 1);
  1010.         LCD_Write_Byte(0xA0, 1);
  1011.         LCD_Write_Byte(0x7C, 1);
  1012.     }
  1013.     break;
  1014.     case 90:
  1015.         //y
  1016.     {
  1017.         LCD_Write_Byte(0x00, 1);
  1018.         LCD_Write_Byte(0x44, 1);
  1019.         LCD_Write_Byte(0x64, 1);
  1020.         LCD_Write_Byte(0x54, 1);
  1021.         LCD_Write_Byte(0x4C, 1);
  1022.         LCD_Write_Byte(0x44, 1);
  1023.     }
  1024.     break;
  1025.     case 91:
  1026.         //z
  1027.     {
  1028.         LCD_Write_Byte(0x14, 1);
  1029.         LCD_Write_Byte(0x14, 1);
  1030.         LCD_Write_Byte(0x14, 1);
  1031.         LCD_Write_Byte(0x14, 1);
  1032.         LCD_Write_Byte(0x14, 1);
  1033.         LCD_Write_Byte(0x14, 1);
  1034.         break;
  1035.         default:
  1036.             LCD_Write_Byte(0x1f, 1);
  1037.             break;
  1038.         }
  1039.     }
  1040. }
  1041. void LCD_Write_English_String(unsigned char X, unsigned char Y, char *s)
  1042. {
  1043.     LCD_Set_XY(X, Y);
  1044.     while (*s)
  1045.     {
  1046.         LCD_Write_Char(*s);
  1047.         s++;
  1048.     }
  1049. }
  1050. void LCD_Write_Number(unsigned char X, unsigned char Y, unsigned char s) //显示一位数字的快速重写
  1051. {
  1052.     switch(s)
  1053.     {
  1054.     case 0:
  1055.         LCD_Write_English_String(X, Y, "0");
  1056.         break;
  1057.     case 1:
  1058.         LCD_Write_English_String(X, Y, "1");
  1059.         break;
  1060.     case 2:
  1061.         LCD_Write_English_String(X, Y, "2");
  1062.         break;
  1063.     case 3:
  1064.         LCD_Write_English_String(X, Y, "3");
  1065.         break;
  1066.     case 4:
  1067.         LCD_Write_English_String(X, Y, "4");
  1068.         break;
  1069.     case 5:
  1070.         LCD_Write_English_String(X, Y, "5");
  1071.         break;
  1072.     case 6:
  1073.         LCD_Write_English_String(X, Y, "6");
  1074.         break;
  1075.     case 7:
  1076.         LCD_Write_English_String(X, Y, "7");
  1077.         break;
  1078.     case 8:
  1079.         LCD_Write_English_String(X, Y, "8");
  1080.         break;
  1081.     case 9:
  1082.         LCD_Write_English_String(X, Y, "9");
  1083.         break;
  1084.     default:
  1085.         LCD_Write_English_String(X, Y, "-");
  1086.         break;
  1087.     }
  1088. }
  1089. void LCD_Clear()
  1090. {
  1091.     int i = 0;
  1092.     for(i = 0; i < 504; i++)
  1093.     {
  1094.         LCD_Write_Byte(0x00, 1); //清屏
  1095.     }
  1096. }
  1097. void LCD_init(void)
  1098. {
  1099.     P2DIR |= BL + DC + CE + RST;
  1100.     P1DIR |= MOSI + SCLK;
  1101.     P1SEL = MOSI + SCLK;
  1102.     USICTL0 |= USISWRST;
  1103.     USICTL0 = USIPE6 + USIPE5 + USIMST + USIOE + USISWRST;
  1104.     USICTL1 |= USIIE + USICKPH;
  1105.     USICKCTL = USIDIV_0 + USISSEL_1;
  1106.     USICTL0 &= ~USISWRST;
  1107.     //复位
  1108.     P2OUT &= ~RST;
  1109.     P2OUT |= RST;
  1110.     P2OUT &= ~CE;
  1111.     P2OUT |= CE;
  1112.     LCD_Write_Byte(0x21, 0); //扩展命令设置模式
  1113.     LCD_Write_Byte(0xc8, 0); //设置偏置电压
  1114.     LCD_Write_Byte(0x06, 0); //温度校正
  1115.     LCD_Write_Byte(0x13, 0); //1:48
  1116.     LCD_Write_Byte(0x20, 0); //使用基本模式
  1117.     LCD_Write_Byte(0x0c, 0);
  1118.     LCD_Write_Byte(0x80, 0);
  1119.     LCD_Clear();
  1120.     LCD_Write_Byte(0x0c, 0); //设置显示模式,正常显示
  1121.     P2OUT &= ~CE;
  1122.     /*
  1123.         USICKCTL = USIDIV_7 + USISSEL_1; //初始化完毕,LCD调为低速接口,
  1124.     */
  1125. }
  1126. void CLKInit()
  1127. {
  1128.     BCSCTL2 = SELM_0 + DIVM_0 + DIVS_3;
  1129.     DCOCTL = 0x00;
  1130.     BCSCTL1 = CALBC1_1MHZ;
  1131.     DCOCTL = CALDCO_1MHZ;
  1132.     BCSCTL1 |= XT2OFF + DIVA_3;
  1133.     BCSCTL3 = XT2S_0 + LFXT1S_2 + XCAP_1;
  1134. }
  1135. long GetTemp()
  1136. {
  1137.     ADC10CTL1 = INCH_10 + ADC10DIV_3;
  1138.     ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE;
  1139.     ADC10CTL0 |= ENC + ADC10SC;
  1140.     __bis_SR_register(CPUOFF + GIE);
  1141.     return ADC10MEM;
  1142. }
  1143. void PrintTempFirstInit()
  1144. {
  1145.     LCD_Write_English_String(0, 0, "Temp:");
  1146.     //写入单条,温度的符号.
  1147.     LCD_Set_XY(41, 0); //记住,倒着写的.
  1148.     {
  1149.         LCD_Write_Byte(0x03, 1);
  1150.         LCD_Write_Byte(0x03, 1);
  1151.         LCD_Write_Byte(0x00, 1);
  1152.         LCD_Write_Byte(0x7E, 1);
  1153.         LCD_Write_Byte(0x42, 1);
  1154.         LCD_Write_Byte(0x42, 1);
  1155.     }
  1156. }
  1157. void PrintTemp()
  1158. {
  1159.     int IntDegC = 100;
  1160.     do
  1161.     {
  1162.         IntDegC = ((GetTemp() - 673) * 423) / 1024;
  1163.     }
  1164.     while(IntDegC > 100 || IntDegC < 0);
  1165.     IntDegC -= 10;
  1166.     LCD_Write_Number(29, 0, IntDegC / 10);
  1167.     LCD_Write_Number(35, 0, IntDegC % 10);
  1168. }
  1169. void TickInit()
  1170. {
  1171.     TA0CCTL0 = CM_0 + CCIS_0 + OUTMOD_0 + CCIE;
  1172.     TA0CCR0 = 1499;
  1173.     /*
  1174.      * TASSEL_1 -- ACLK
  1175.      * ID_0 -- Divider - /1
  1176.      * MC_1 -- Up Mode
  1177.      */
  1178.     TA0CTL = TASSEL_1 + ID_0 + MC_1;
  1179. }
  1180. void CalcWeek(){
  1181.     //基姆拉尔森计算公式
  1182.            int iWeek = (DATE + 2 * MONTH + 3 * (MONTH + 1) / 5 + YEAR + YEAR / 4 - YEAR / 100 + YEAR / 400) % 7;
  1183.             LCD_Write_English_String(0, 3, "         ");//清空行...
  1184.             switch(iWeek)
  1185.             {
  1186.             case 0:
  1187.                 LCD_Write_English_String(0, 3, "Monday");
  1188.                 break;
  1189.             case 1:
  1190.                 LCD_Write_English_String(0, 3, "Tuesday");
  1191.                 break;
  1192.             case 2:
  1193.                 LCD_Write_English_String(0, 3, "Wednesday");
  1194.                 break;
  1195.             case 3:
  1196.                 LCD_Write_English_String(0, 3, "Thursday");
  1197.                 break;
  1198.             case 4:
  1199.                 LCD_Write_English_String(0, 3, "Friday");
  1200.                 break;
  1201.             case 5:
  1202.                 LCD_Write_English_String(0, 3, "Saturday");
  1203.                 break;
  1204.             case 6:
  1205.                 LCD_Write_English_String(0, 3, "Sunday");
  1206.                 break;
  1207.             }
  1208. }
  1209. void ClockTick()
  1210. {
  1211.     unsigned char Days;
  1212.     if(LCD_BL > 0){
  1213.         //如果不想屏幕关闭可以加上这一行.
  1214.         LCD_BL++;
  1215.         LCD_BL--;
  1216.         if(!LCD_BL){
  1217.             P2OUT &=~ BL;
  1218.         }
  1219.     }else{
  1220.         if(LCD_DS >0 ){
  1221.             LCD_DS--;
  1222.             if(!LCD_DS){
  1223.                 P2OUT &= ~RST;
  1224.             }
  1225.         }else{
  1226.             return;
  1227.         }
  1228.     }
  1229.     SECOND++;
  1230.     LCD_Write_Number(48, 2, SECOND / 10);
  1231.     LCD_Write_Number(54, 2, SECOND % 10);
  1232.     if(SECOND >= 60)
  1233.     {
  1234.         MINUTE++;
  1235.         SECOND = 0;
  1236.         LCD_Write_Number(30, 2, MINUTE / 10);
  1237.         LCD_Write_Number(36, 2, MINUTE % 10);
  1238.     }
  1239.     if(MINUTE >= 60)
  1240.     {
  1241.         HOUR++;
  1242.         MINUTE = 0;
  1243.         LCD_Write_Number(12, 2, HOUR / 10);
  1244.         LCD_Write_Number(18, 2, HOUR % 10);
  1245.     }
  1246.     if(HOUR >= 24)
  1247.     {
  1248.         DATE++;
  1249.         HOUR = 0;
  1250.         LCD_Write_Number(60, 1, DATE / 10);
  1251.         LCD_Write_Number(66, 1, DATE % 10);
  1252.         CalcWeek();
  1253.      }
  1254.     //处理闰年2月
  1255.     if(MONTH == 2)
  1256.     {
  1257.         if(!(YEAR % 4))
  1258.         {
  1259.             Days = 29;
  1260.         }
  1261.         else
  1262.         {
  1263.             Days = 28;
  1264.         }
  1265.         if(!(YEAR % 400))
  1266.         {
  1267.             Days = 28;
  1268.         }
  1269.     }
  1270.     else
  1271.     {
  1272.         switch(MONTH)
  1273.         {
  1274.         case 1:
  1275.             Days = 31;
  1276.             break;
  1277.         case 3:
  1278.             Days = 31;
  1279.             break;
  1280.         case 4:
  1281.             Days = 30;
  1282.             break;
  1283.         case 5:
  1284.             Days = 31;
  1285.             break;
  1286.         case 6:
  1287.             Days = 30;
  1288.             break;
  1289.         case 7:
  1290.             Days = 31;
  1291.             break;
  1292.         case 8:
  1293.             Days = 31;
  1294.             break;
  1295.         case 9:
  1296.             Days = 30;
  1297.             break;
  1298.         case 10:
  1299.             Days = 31;
  1300.             break;
  1301.         case 11:
  1302.             Days = 30;
  1303.             break;
  1304.         case 12:
  1305.             Days = 31;
  1306.             break;
  1307.         }
  1308.     }
  1309.     if(DATE > Days)
  1310.     {
  1311.         MONTH++;
  1312.         DATE = 1;
  1313.         LCD_Write_Number(42, 1, MONTH / 10);
  1314.         LCD_Write_Number(48, 1, MONTH % 10);
  1315.     }
  1316.     if(MONTH > 12)
  1317.     {
  1318.         YEAR++;
  1319.         MONTH = 1;
  1320.         LCD_Write_Number(24, 1, YEAR / 10);
  1321.         LCD_Write_Number(30, 1, YEAR % 10);
  1322.     }
  1323.     if(YEAR >= 100)
  1324.     {
  1325.         YEAR = 0; //100年是上限
  1326.     }
  1327. }
  1328. void ClockInit(){
  1329.           LCD_Write_English_String(0, 1, "D:");
  1330.         LCD_Write_English_String(12, 1, "20");
  1331.         LCD_Write_Number(24, 1, YEAR / 10);
  1332.         LCD_Write_Number(30, 1, YEAR % 10);
  1333.         LCD_Write_English_String(36, 1, "-");
  1334.         LCD_Write_Number(42, 1, MONTH / 10);
  1335.         LCD_Write_Number(48, 1, MONTH % 10);
  1336.         LCD_Write_English_String(54, 1, "-");
  1337.         LCD_Write_Number(60, 1, DATE / 10);
  1338.         LCD_Write_Number(66, 1, DATE % 10);
  1339.         LCD_Write_English_String(0, 2, "T:");
  1340.         LCD_Write_Number(12, 2, HOUR / 10);
  1341.         LCD_Write_Number(18, 2, HOUR % 10);
  1342.         LCD_Write_English_String(24, 2, ":");
  1343.         LCD_Write_Number(30, 2, MINUTE / 10);
  1344.         LCD_Write_Number(36, 2, MINUTE % 10);
  1345.         LCD_Write_English_String(42, 2, ":");
  1346.         LCD_Write_Number(48, 2, SECOND / 10);
  1347.         LCD_Write_Number(54, 2, SECOND % 10);
  1348.         CalcWeek();
  1349. }
  1350. void TickOnTimer()
  1351. {
  1352.     PrintTemp();
  1353.     ClockTick();
  1354. }
  1355. void GPIOInit(){
  1356.     P1IE = BIT3;
  1357.     P2OUT |= BL;
  1358. }
  1359. void NoTimerInit(){
  1360.     WDTCTL = WDTPW | WDTHOLD;
  1361.     CLKInit();
  1362.     LCD_init();
  1363.     PrintTempFirstInit();
  1364.     PrintTemp();
  1365.     ClockInit();
  1366.     ClockTick();
  1367.     GPIOInit();
  1368.     //心跳最后初始化
  1369.     TickInit();
  1370. }
  1371. void main(void)
  1372. {
  1373.     NoTimerInit();
  1374.     P2OUT |= BL;
  1375.     for(;;)
  1376.     {
  1377.         _BIS_SR(LPM3_bits + GIE);
  1378.         TickOnTimer();
  1379.         //部分擦除
  1380.     }
  1381. }
  1382. #pragma vector=USI_VECTOR
  1383. __interrupt void USI_ISR_HOOK(void)
  1384. {
  1385.     if (USICTL1 & USIIFG)
  1386.     {
  1387.         USICTL1 &= ~USIIFG;
  1388.         _bic_SR_register_on_exit(LPM3_bits + GIE);
  1389.     }
  1390.     if (USICTL1 & USISTTIFG)
  1391.     {
  1392.         //无动作
  1393.     }
  1394. }
  1395. #pragma vector=ADC10_VECTOR
  1396. __interrupt void ADC10_ISR_HOOK(void)
  1397. {
  1398.     __bic_SR_register_on_exit(CPUOFF);
  1399. }
  1400. //定时器是单源中断
  1401. #pragma vector=TIMER0_A0_VECTOR
  1402. __interrupt void TIMER0_A0_ISR_HOOK(void)
  1403. {
  1404.     _bic_SR_register_on_exit(LPM3_bits + GIE);
  1405. }
  1406. #pragma vector=PORT1_VECTOR
  1407. __interrupt void PORT1_ISR_HOOK(void)
  1408. {
  1409.     if((P1IFG&BIT3) == BIT3)
  1410.     {
  1411.         LCD_BL += 30;
  1412.         LCD_DS = 30;
  1413.         NoTimerInit();
  1414.     }else{
  1415.         LCD_DS = 2;
  1416.     }
  1417. }

因为内存实在小的恐怖,所以不能用const写数字的模了。






这个不含大字版本,大字版本在我微博里面有得下载,而且好像有点BUG。


加点专家和M???
本文内容包含图片或附件,获取更多资讯,请 登录 后查看;或者 注册 成为会员获得更多权限
本帖最近打赏记录:共4条打赏 ,M币+18
离线zhuowinner
发帖
509
M币
65
专家
1
粉丝
13
只看该作者 1楼 发表于: 2013-03-17
请登录后查看
离线icebaby

发帖
530
M币
4787
专家
2
粉丝
32
只看该作者 2楼 发表于: 2013-03-17
请登录后查看
本帖最近打赏记录:共1条打赏 ,M币+1
离线icebaby

发帖
530
M币
4787
专家
2
粉丝
32
只看该作者 3楼 发表于: 2013-03-17
请登录后查看
本帖最近打赏记录:共1条打赏 ,M币+1
离线icebaby

发帖
530
M币
4787
专家
2
粉丝
32
只看该作者 4楼 发表于: 2013-03-17
请登录后查看
离线zhang_yy007

发帖
2839
M币
1518
专家
6
粉丝
62
只看该作者 5楼 发表于: 2013-11-03
请登录后查看
离线xlfsrmm

发帖
1228
M币
5369
专家
2
粉丝
31
只看该作者 6楼 发表于: 2013-11-04
请登录后查看
快速回复
限80 字节
温馨提示:欢迎交流讨论,请勿发布纯表情、纯引用等灌水帖子;以免被删除
 
上一个 下一个