找回密码
 立即注册

QQ登录

只需一步,快速开始

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

MC96F7416S关于LCD的代码

[复制链接]
跳转到指定楼层
楼主
ID:427656 发表于 2018-11-16 13:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
供大家分享

单片机源程序如下:
  1. //******************************************************************  
  2. //        Project : Remmocon application Program
  3. //        Device  : MC96F7416S
  4. //        Date          : '2013.11.21~
  5. //        Author  : nakwon.ma  
  6. //
  7. //        File          :
  8. //                    Variable.h         Global variable define
  9. //                    Main.c                main frame structure
  10. //                    Key.c                Key scan and execute  
  11. //                    Time.c                clock function
  12. //                    Lcd.c                Lcd Display
  13. //
  14. //
  15. //        History :
  16. //       
  17. //        1. 2013.11.21        Program coding start
  18. //
  19. //******************************************************************  

  20. //------------------------------------------------------------------
  21. //        Include file and variable
  22. //------------------------------------------------------------------

  23. #include <intrins.h>
  24. //#include "MC96F7616A.h"
  25. #include "MC96F7416S.h"
  26. #include "def.h"

  27. #define  MyDef                                        // global variable
  28. #include "Variable.h"                                // User variable define  

  29. //------------------------------------------------------------------
  30. //        external prototype function       
  31. //------------------------------------------------------------------

  32. extern void Process_Key();                        // Key.c               
  33. extern void Read_Self_Bias();                //

  34. extern void Process_Time();                 //Time.c                         
  35. //extern void Wait_uSec();

  36. extern void Process_Lcd();                        // Lcd.c                                         
  37. extern void Lcd_Initialize();                        //


  38. //extern void Tx_RemoconSig();                        // Key.c               
  39. //extern void Wait_uSec(Word);        //
  40. extern void Wait_uSec(DELAY);        //

  41. //extern void Wait_uSec();        //


  42. //==================================================================
  43. //        Peripheral Register Initialize   
  44. //==================================================================  

  45. static void Initial( void )                                               
  46. {
  47. #if 0        //w



  48. #else

  49.         //Xout_Xin function setting
  50.         P9FSR =0        //Port9 Function Selection Register
  51.                 |(0<<2)        //0:P93 Port (EINT10 function possible when input), 1:T0O/PWM0O Function
  52.                 |(0<<1)        //0:P91 Port, 1:XOUT Function
  53.                 |(0<<0)        //0:P90 port, 1:XIN Function
  54.                 ;

  55. //7416S绰 reset pin 绝澜
  56.         /*--- Set Port_9 --------------------------------------------------------------------
  57.          * P9.3 : Dout,NOT_USED        1
  58.          *   .2 : Din, NOT_USED                0       
  59.          *   .1 : Dout, NOT_USED        1
  60.          *   .0 : Dout, NOT_USED        1
  61.          *-----------------------------------------------------------------------------------
  62.            */
  63.         P9         =  _0000_0000;                 // P9 Data Register
  64.         P9IO    =  _1111_1011;         // P9 Direction Register                        //0:input, 1:output
  65.         P9OD    =  _0000_0000;         // P9 Open-drain Selection Register                 //0:push-pull, 1:open-drain
  66.         P9PU    =  _0000_0100;         // P9 Pull-up Resistor Selection Register         //0:disable, 1:enable        
  67.        
  68.         /*--- Oscillator Control ----------------------------------------------------------------
  69.            * OSCCR         : 0000 0000 = 0x00                        : Oscillator Control Register
  70.          * OSCCR        = 0x00;                // initial int_1Mhz,int_osc enable,main_osc enable,sub_osc enalbe          
  71.            *-----------------------------------------------------------------------------------
  72.            */
  73.         OSCCR =0        //Oscillator Control Register
  74.                 |(1<<3)        //0:int_0_5Mhz, 1:int_1Mhz, 2:int_2Mhz, 3: int_4Mhz        //6832客 促抚
  75.                 |(0<<2)        //0:int_osc enable, 1:int_osc disable
  76.                 |(0<<1)        //0:main_osc disable, 1:main_osc enable
  77.                 |(1<<0)        //0:sub_osc disable, 1:sub_osc enable        //sub_osc enable老 版快 2uA 家葛
  78.                 //|(0<<0)        //0:sub_osc disable, 1:sub_osc enable        //sub_osc enable老 版快 2uA 家葛
  79.                 ;
  80. //2013_11_21 by nakwon test

  81.         //internal fx=1Mhz, bit clock 1Mhz/4096=4ms, overflow period=bit clock* 4= 16ms
  82.         //        BITCR=(1<<3)|(1<<0);        // BIT counter clear!!
  83.         //        while((BITCR&0x80)==0);        // BIT 救沥拳 16ms wait time @ int_osc 1Mhz

  84.         //NOTE!!! PwrSave Mode (fsub=500mSec Delay for stabilization)
  85.         //for test port setting
  86.         //P4         =  _0000_0000; // P4 Data Register
  87.         //P4IO    =  _1111_1111; // P4 Direction Register                        //0:input, 1:output
  88.         //P4OD    =  _0000_0000; // P4 Open-drain Selection Register                 //0:push-pull, 1:open-drain
  89.         //P4PU    =  _0000_0000; // P4 Pull-up Resistor Selection Register         //0:disable, 1:enable
  90.        
  91.         //P40 = 1;        //救利拳 test 侩

  92.         //sub_osc enable stabilization time 1s
  93.     Wait_uSec(60000);               //about 270ms @ INT_OSC 1Mhz(7416S)
  94.     Wait_uSec(60000);               //
  95.     Wait_uSec(60000);               //
  96.     Wait_uSec(60000);               //

  97.         //P40 = 0;        //救利拳 test 侩
  98.        
  99.         /*--- Set System and Clock Control ------------------------------------------------------
  100.            * SCCR         : 0000 0000 = 0x00                        : System and Clock Control Register.
  101.            * SCCR        = 0x01;        // wons,psave,-,-,-,-,sclk1,sclk0
  102.            *-----------------------------------------------------------------------------------
  103.            */

  104. //2013_11_21 by nakwon FLL test

  105.         FLLCR |= _0000_1011;                //FLL enable, 7.995MHz
  106.         //FLLCR |= _0000_0011;                //FLL enable, 3.998MHz

  107.         //P40 = 1;        //救利拳 test 侩
  108.         //FLL enalbe stabilization time about 16ms
  109.         //internal fx=1Mhz, bit clock 1Mhz/4096=4ms, overflow period=bit clock* 4= 16ms
  110.         BITCR=(1<<3)|(1<<0);        // BIT counter clear!!
  111.         while((BITCR&0x80)==0);        // BIT 救沥拳 16ms wait time @ int_osc 1Mhz

  112.         //P40 = 0;        //救利拳 test 侩

  113.         //INT_OSC--> FLL clock change!!
  114.         SCCR =0                //System and Clock Control Register
  115.                 |(0<<7)        //0:WDTRCOSC disable at stop mode, 1:WDTRCOSC enable at stop mode
  116.                 //|(0<<6)        //0:power save disable, 1:power save enable
  117.                 |(1<<6)        //0:power save disable, 1:power save enable        //p save mode enable矫 4uA 临烙
  118.                 |(3<<0)        //0:INT_RC OSC, 1:external OSC, 2:external sub_osc, 3:FLL
  119.                 ;
  120.        
  121.         // int_osc disable & main_osc enable,sub_osc enable!!
  122.         // INT_OSC disable
  123.         OSCCR|=(1<<2);        //0:int_osc enable, 1:int_osc disable
  124.        
  125.           /*--- Set Basic Timer ---------------------------------------------------------------
  126.            * BITCR         : 0000 0000 = 0x00                        : Basic Timer Control Register
  127.            * BITCR         = 0x01;        // bitifr,-,-,-,bclr,bck2,bck1,bck0
  128.          *        / fx=8Mhz, bit clock 8Mhz/4096=0.5ms, overflow period=bit clock* 4= 2ms
  129.            *-----------------------------------------------------------------------------------
  130.            */
  131.         BITCR =0        //Oscillator Control Register
  132.                 |(0<<7)        //0:BIT Interrupt no generation, 1:BIT Interrupt generation
  133.                 |(0<<5)//0:fx/4096, 1:fx/1024, 2:fx/128, 3: fx/16       
  134.                 |(0<<3)        //0:Free running, 1:Clear counter
  135.                 |(1<<0)        //0:Clock*2, 1:Clock*4, 2:Clock*8, 3:Clock*16, 4:Clock*32, 5:Clock*64, 6:Clock*128, 7:Clock*256
  136.                 ;

  137.         //LVRCR = 0x00;        //LVREN[0]= 0: LVR enable, 1:LVR disable                         // enable 矫 12uA ~~14uA 家葛  
  138.         LVRCR = 0x01;        //LVREN[0]= 0: LVR enable, 1:LVR disable                         //
  139.       
  140.           /*--- Set WATCH DOG TIMER ----------------------------------------------------------
  141.            * WDT Interrupt Interval=(BIT Interrupt Interval)*(WDTDR Value +1)
  142.          * WDT Interrupt Interval=4ms*(0xff + 1)= 1s
  143.            *-----------------------------------------------------------------------------------
  144.            */
  145.            //WDT disable
  146.         //WDTCR = 0xE0;        // wdten,wdtrson,wdtcl,-,-,-,-,wdtifr   WDT Enable! org
  147.         WDTCR = 0x00;        // wdten,wdtrson,wdtcl,-,-,-,-,wdtifr   WDT disable!!        犬牢
  148.        
  149.         /*--- Set Watch Timer (0.5Sec Interval INT) -----------------------------------------
  150.              * wtenable,2hz,fsub=32.768khz(0.5sec interval)
  151.          * WTCR = 0x98;        //WTEN,-,-,WTIFR,WTIN1,WTIN0,WTCK1,WTCK0 // WT Enable
  152.            *-----------------------------------------------------------------------------------
  153.            */

  154. //lcd 备悼阑 sub osc肺 且 版快 救沥拳 time捞 鞘夸窃 !!
  155. //WT 1min interrupte
  156.        WTDR    =  0x77; // Watch Timer Data Register // Sub Clock fsub /( 2*14 x (count+1) )= 1盒

  157.         WTCR =0        //Oscillator Control Register
  158.                 |(1<<7)        //0:WT disable, 1:WT enable
  159.                 |(1<<4)        //0:WT int no gen, 1:WT int gen
  160.                 |(3<<2)        //0:fwck/2^7, 1:fwck/2^13, 2:fwck/2^14, 3: fwck/(2^14*(WTDR value+1))
  161.                 |(0<<0)//0:fsub, 1:fx/256, 2:fx/128, 3: fx/64                        //sub osc change!!//org
  162.                 //|(1<<0)//0:fsub, 1:fx/256, 2:fx/128, 3: fx/64                        //fx/256 clock change!!
  163.                 ;

  164.         /*--- Set Port Function Selection control ------------------------------------------------
  165.          *  port setting and PFSR setting
  166.          *-----------------------------------------------------------------------------------
  167.            */
  168. //7416S狼 版快        
  169.         /*--- Set Port_0 --------------------------------------------------------------------
  170.          * P0.7 : Dout,  REM_OUT                1, PP
  171.          *   .6 : x
  172.          *   .5 : x
  173.          *   .4 : x
  174.          *   .3 : Dout,        NOT_USED                1, PP
  175.          *   .2 : x
  176.          *   .1 : x
  177.          *   .0 : x
  178.          *-----------------------------------------------------------------------------------
  179.            */
  180.         P0         =  _0000_0000; // P0 Data Register
  181.         P0IO    =  _1000_1000; // P0 Direction Register                                //0:input, 1:output
  182.         P0OD    =  _0000_0000; // P0 Open-drain Selection Register                 //0:push-pull, 1:open-drain
  183.         P0PU    =  _0111_0111; // P0 Pull-up Resistor Selection Register         //0:disable, 1:enable
  184.         P0DB    =  _0000_0000; // P0 Debounce Enable Register                         //0:disable, 1:enable       

  185. //rem out function 眠啊
  186.         P03FSR =0        //Port 0/3 Function Selection Register
  187.                 //|(0<<7)        //0:P33 port, 1:TXD
  188.                 //|(0<<6)        //0:P32 port, 1:T2O/PWM2O
  189.                 //|(0<<5)        //0:P31 port, 1:T3O/PWM3O
  190.                 |(0<<4)        //0:P30 port, 1:LVIREF
  191.                 |(1<<3)        //0:P07 port, 1:REM
  192.                 //|(0<<2)        //0:P05 port, 1:SO
  193.                 //|(0<<1)        //0:P04 port, 1:SCK-out
  194.                 |(0<<0)        //0:P03 port, 1:BUZO
  195.                 ;
  196. /*
  197.         P03FSR =0        //Port 0/3 Function Selection Register
  198.                 |(0<<7)        //0:P33 port, 1:TXD
  199.                 |(0<<6)        //0:P32 port, 1:T2O/PWM2O        //7616A俊绰 绝澜. 0 setting!!
  200.                 |(0<<5)        //0:P31 port, 1:T3O/PWM3O        //7616A俊绰 绝澜. 0 setting!!
  201.                 |(0<<4)        //0:P30 port, 1:LVIREF
  202.                 |(0<<3)        //0:P07 port, 1:REM
  203.                 |(0<<2)        //0:P05 port, 1:SO                        //7616A俊绰 绝澜. 0 setting!!
  204.                 |(0<<1)        //0:P04 port, 1:SCK-out                //7616A俊绰 绝澜. 0 setting!!
  205.                 |(0<<0)        //0:P03 port, 1:BUZO
  206.                 ;
  207. */               
  208.           /*--- Set Port_1 --------------------------------------------------------------------
  209.          * P1.7 : Din,  KIN_2                0,  PU
  210.          *   .6 : Din,  KIN_1                0,  PU
  211.          *   .5 : Din,  x        0,  PU
  212.          *   .4 : Din,  x        0,  PU
  213.          *   .3 : Din,        x        0, PU
  214.          *   .2 : Din,        x        0, PU
  215.          *   .1 : Din,        x        0, PU
  216.          *   .0 : Din,        KIN_0        0, PU
  217.          *-----------------------------------------------------------------------------------
  218.            */
  219.         P1         =  _0000_0000; // P1 Data Register
  220.         P1IO    =  _0000_0000; // P1 Direction Register                                //0:input, 1:output
  221.         P1OD    =  _0000_0000; // P1 Open-drain Selection Register                 //0:push-pull, 1:open-drain
  222.         P1PU    =  _1111_1111; // P1 Pull-up Resistor Selection Register         //0:disable, 1:enable        org
  223.         P1DB    =  _0000_0000; // P1 Debounce Enable Register                         //0:disable, 1:enable


  224.         P1FSR =0        //Port 1 Function Selection Register
  225.                 //|(0<<3)        //0:P13 Port (EINT3 function possible when input), 1:AN7
  226.                 //|(0<<2)        //0:P12 Port (EINT2 function possible when input), 1:AN6
  227.                 //|(0<<1)        //0:P11 Port (EINT1 function possible when input), 1:AN5
  228.                 |(0<<0)        //0:P10 Port (EINT0 function possible when input), 1:AN4
  229.                 ;        
  230.         /*--- Set Port_2 --------------------------------------------------------------------
  231.          * P2.7 : Ain,        ADC3                0, ADC3
  232.          *   .6 : Dout,        NOT_USED        1, PP
  233.          *   .5 : Dout,        NOT_USED        1, PP
  234.          *   .4 : Dout,        x        1, PP
  235.          *   .3 : Dout,        NOT_USED        1, PP
  236.          *   .2 : Dout,        NOT_USED        1, PP
  237.          *   .1 : Dout, x        1, PP
  238.          *   .0 : Dout,        x        1, PP
  239.          *-----------------------------------------------------------------------------------
  240.            */

  241.         P2         =  _0000_0000; // P2 Data Register
  242.         P2IO    =  _0111_1111; // P2 Direction Register                                //0:input, 1:output
  243.         P2OD    =  _0000_0000; // P2 Open-drain Selection Register ??                //0:push-pull, 1:open-drain
  244.         P2PU    =  _0000_0000; // P2 Pull-up Resistor Selection Register         //0:disable, 1:enable
  245.        
  246.         P2FSR =0        //Port 2 Function Selection Register
  247.                 |(1<<7)        //0:P27 port, 1:AN3
  248.                 |(0<<6)        //0:P26 port, 1:AN2
  249.                 |(0<<5)        //0:P25 port, 1:AN1
  250.                 //|(0<<4)        //0:P24 port, 1:AN0
  251.                 |(0<<3)        //0:P23 port, 1:SEG36
  252.                 |(0<<2)        //0:P22 port, 1:SEG35
  253.                 //|(0<<1)        //0:P21 port, 1:SEG34
  254.                 //|(0<<0)        //0:P20 port, 1:SEG33
  255.                 ;

  256. //7616S狼 版快                
  257.         /*--- Set Port_3 --------------------------------------------------------------------
  258.          * P3.4 : Dout,x        1, PP
  259.          *   .3 : Dout,        x        1, PP
  260.          *   .2 : x
  261.          *   .1 : x
  262.          *   .0 : Din,        Key4        1, PP,         // 犬牢 !!
  263.          *-----------------------------------------------------------------------------------
  264.            */
  265.         P3         =  _0000_0000; // P3 Data Register
  266.         P3IO    =  _0001_1000; // P3 Direction Register                        //0:input, 1:output
  267.         P3OD    =  _0000_0000; // P3 Open-drain Selection Register                 //0:push-pull, 1:open-drain
  268.         P3PU    =  _0000_0111; // P3 Pull-up Resistor Selection Register         //0:disable, 1:enable               
  269.        
  270.         /*--- Set Port_4 --------------------------------------------------------------------
  271.          * P4.7 : Dout, LCD_COM1        1, LCD
  272.          *   .6 : Dout, LCD_COM0        1, LCD
  273.          *   .5 : Dout, NOT_USED
  274.          *   .4 : Dout, NOT_USED
  275.          *   .3 : Dout, NOT_USED
  276.          *   .2 : Dout, NOT_USED
  277.          *   .1 : Dout, NOT_USED
  278.          *   .0 : Dout, NOT_USED
  279.          *-----------------------------------------------------------------------------------
  280.            */
  281.         P4         =  _0000_0000; // P4 Data Register
  282.         P4IO    =  _1111_1111; // P4 Direction Register                        //0:input, 1:output
  283.         P4OD    =  _0000_0000; // P4 Open-drain Selection Register                 //0:push-pull, 1:open-drain
  284.         P4PU    =  _0000_0000; // P4 Pull-up Resistor Selection Register         //0:disable, 1:enable

  285.         //cap bais mode
  286.         P4FSR =0        //Port 4 Function Selection Register
  287.                 |(1<<7)        //0:P47 port, 1:COM1/SEG0
  288.                 |(1<<6)        //0:P46 port, 1:COM0
  289.                 |(1<<5)        //0:P45 port, 1:CAPL
  290.                 |(1<<4)        //0:P44 port, 1:CAPH
  291.                 |(1<<3)        //0:P43 port, 1:VLC3
  292.                 |(1<<2)        //0:P42 port, 1:VLC2
  293.                 |(1<<1)        //0:P41 port, 1:VLC1
  294.                 |(1<<0)        //0:P40 port, 1:VLC0
  295.                 ;
  296.         /*
  297.         //internal bais mode
  298.         P4FSR =0        //Port 4 Function Selection Register
  299.                 |(1<<7)        //0:P47 port, 1:COM1/SEG0
  300.                 |(1<<6)        //0:P46 port, 1:COM0
  301.                 |(0<<5)        //0:P45 port, 1:CAPL
  302.                 |(0<<4)        //0:P44 port, 1:CAPH
  303.                 |(0<<3)        //0:P43 port, 1:VLC3
  304.                 |(0<<2)        //0:P42 port, 1:VLC2
  305.                 |(0<<1)        //0:P41 port, 1:VLC1
  306.                 |(0<<0)        //0:P40 port, 1:VLC0
  307.                 ;
  308.         */
  309. //7616S狼 版快                
  310.         /*--- Set Port_5 --------------------------------------------------------------------
  311.          * P5.7 : x
  312.          *   .6 : x
  313.          *   .5 : x
  314.          *   .4 : x
  315.          *   .3 : x
  316.          *   .2 : x
  317.          *   .1 : x
  318.          *   .0 : x
  319.          *-----------------------------------------------------------------------------------
  320.            */
  321.         P5         =  _0000_0000; // P5 Data Register
  322.         P5IO    =  _1111_1111; // P5 Direction Register                        //0:input, 1:output
  323.         P5OD    =  _0000_0000; // P5 Open-drain Selection Register                 //0:push-pull, 1:open-drain
  324.         P5PU    =  _0000_0000; // P5 Pull-up Resistor Selection Register         //0:disable, 1:enable

  325.         P5FSR =0        //Port 5 Function Selection Register
  326.                 |(0<<7)        //0:P57 port, 1:SEG32        //7616A俊绰 绝澜. 0 setting!!
  327.                 |(0<<6)        //0:P56 port, 1:SEG31        //7616A俊绰 绝澜. 0 setting!!
  328.                 |(0<<5)        //0:P55 port, 1:SEG30        //7616A俊绰 绝澜. 0 setting!!
  329.                 |(0<<4)        //0:P54 port, 1:SEG29        //7616A俊绰 绝澜. 0 setting!!
  330.                 |(0<<3)        //0:P53 port, 1:SEG28        //7616A俊绰 绝澜. 0 setting!!
  331.                 |(0<<2)        //0:P52 port, 1:SEG27        //7616A俊绰 绝澜. 0 setting!!
  332.                 |(0<<1)        //0:P51 port, 1:SEG26        //7616A俊绰 绝澜. 0 setting!!
  333.                 |(0<<0)        //0:P50 port, 1:SEG25        //7616A俊绰 绝澜. 0 setting!!
  334.                 ;

  335.         /*--- Set Port_6 --------------------------------------------------------------------
  336.          * P6.7 : Dout,NOT_USED        1, LCD
  337.          *   .6 : Dout, NOT_USED        1, LCD
  338.          *   .5 : Dout, NOT_USED        1, LCD
  339.          *   .4 : Dout, NOT_USED        1, LCD
  340.          *   .3 : Dout, NOT_USED        1, LCD
  341.          *   .2 : Dout, NOT_USED        1, LCD
  342.          *   .1 : Dout, NOT_USED        1, LCD
  343.          *   .0 : Dout, NOT_USED        1, LCD
  344.          *-----------------------------------------------------------------------------------
  345.            */
  346.         P6         =  _0000_0000; // P6 Data Register
  347.         P6IO    =  _1111_1111; // P6 Direction Register        //0:input, 1:output
  348.         P6OD    =  _0000_0000; // P6 Open-drain Selection Register //0:push-pull, 1:open-drain
  349.         P6PU    =  _0000_0000; // P6 Pull-up Resistor Selection Register //0:disable, 1:enable

  350.         P6FSR =0        //Port 6 Function Selection Register
  351.                 |(0<<7)        //0:P67 port, 1:SEG24
  352.                 |(0<<6)        //0:P66 port, 1:SEG23
  353.                 |(0<<5)        //0:P65 port, 1:SEG22
  354.                 |(0<<4)        //0:P64 port, 1:SEG21
  355.                 |(0<<3)        //0:P63 port, 1:SEG20
  356.                 |(0<<2)        //0:P62 port, 1:SEG19
  357.                 |(0<<1)        //0:P61 port, 1:SEG18
  358.                 |(0<<0)        //0:P60 port, 1:SEG17
  359.                 ;       
  360.         /*--- Set Port_7 --------------------------------------------------------------------
  361.          * P7.7 : Dout,LCD_SEG16        1, LCD
  362.          *   .6 : Dout, LCD_SEG15        1, LCD
  363.          *   .5 : Dout, LCD_SEG14        1, LCD
  364.          *   .4 : Dout, LCD_SEG13        1, LCD
  365.          *   .3 : Dout, LCD_SEG12        1, LCD
  366.          *   .2 : Dout, LCD_SEG11        1, LCD
  367.          *   .1 : Dout, LCD_SEG10        1, LCD
  368.          *   .0 : Dout, LCD_SEG9        1, LCD         
  369.          *-----------------------------------------------------------------------------------
  370.            */
  371.         P7         =  _0000_0000; // P7 Data Register
  372.         P7IO    =  _1111_1111; // P7 Direction Register                        //0:input, 1:output
  373.         P7PU    =  _0000_0000; // P7 Pull-up Resistor Selection Register         //0:disable, 1:enable

  374.         P7FSR =0        //Port 7 Function Selection Register
  375.                 |(1<<7)        //0:P77 port, 1:SEG16
  376.                 |(1<<6)        //0:P76 port, 1:SEG15
  377.                 |(1<<5)        //0:P75 port, 1:SEG14
  378.                 |(1<<4)        //0:P74 port, 1:SEG13
  379.                 |(1<<3)        //0:P73 port, 1:SEG12
  380.                 |(1<<2)        //0:P72 port, 1:SEG11
  381.                 |(1<<1)        //0:P71 port, 1:SEG10
  382.                 |(1<<0)        //0:P70 port, 1:SEG9
  383.                 ;
  384.        
  385.         /*--- Set Port_8 --------------------------------------------------------------------
  386.          * P8.7 : Dout,x        1, LCD
  387.          *   .6 : Dout, x        1, LCD
  388.          *   .5 : Dout, x        1, LCD
  389.          *   .4 : Dout, x        1, LCD
  390.          *   .3 : Dout, LCD_SEG4        1, LCD
  391.          *   .2 : Dout, LCD_SEG3        1, LCD
  392.          *   .1 : Dout, LCD_COM3        1, LCD
  393.          *   .0 : Dout, LCD_COM2        1, LCD               
  394.          *-----------------------------------------------------------------------------------
  395.            */
  396.         P8         =  _0000_0000; // P8 Data Register
  397.         P8IO    =  _1111_1111; // P8 Direction Register                        //0:input, 1:output
  398.         P8PU    =  _0000_0000; // P8 Pull-up Resistor Selection Register         //0:disable, 1:enable

  399.         P8FSR =0        //Port 8 Function Selection Register
  400.                 //|(1<<7)        //0:P87 port, 1:SEG8
  401.                 //|(1<<6)        //0:P86 port, 1:SEG7
  402.                 //|(1<<5)        //0:P85 port, 1:COM7/SEG6
  403.                 //|(1<<4)        //0:P84 port, 1:COM6/SEG5
  404.                 |(1<<3)        //0:P83 port, 1:COM5/SEG4
  405.                 |(1<<2)        //0:P82 port, 1:COM4/SEG3
  406.                 |(1<<1)        //0:P81 port, 1:COM3/SEG2
  407.                 |(1<<0)        //0:P80 port, 1:COM2/SEG1
  408.                 ;

  409. //peri setting

  410.           /*--- Set Timer0 (8-Bit, 4mSec Interval) -------------------------------------------
  411.            * T0CR         : 0000 0000 = 0x00                : Timer0 Control Register
  412.            * T0DR         : 249                                         : Timer0 Data Register
  413.            * interrupt 林扁 = 16*(T0DR+1) = 16*250 = 4msSec
  414.            *-----------------------------------------------------------------------------------
  415.            */
  416.   /*         
  417.         T0CR =        0x00;
  418.         T0DR =        249;                // 128 /8Mhz=16us, intrupte 林扁 =16uSec(T0DR + 1 ) = 4msSec
  419.         T0CR =0
  420.                 |(1<<7)        //0:Timer0 disable, 1:Timer0 enable
  421.                 |(0<<4)        //0:0:Timer0/counter, 1:PWM, 2:capture
  422.                 |(4<<1)        //0:fx/2, 1:fx/4, 2:fx/8, 3:fx/32, 4:fx/128, 5:fx/512, 6:fx/2048, 7:EC0
  423.                 |(1<<0)        //0:Clear Timer 0 Counter no effect, 1:Clear Timer 0 Counter auto clear
  424.                 ;
  425. */
  426.            
  427. //林扁 函版
  428.           /*--- Set Timer0 (8-Bit, 0.5mSec Interval) -------------------------------------------
  429.            * T0CR         : 0000 0000 = 0x00                : Timer0 Control Register
  430.            * T0DR         : 124                                         : Timer0 Data Register
  431.            * interrupt 林扁 = 4*(T0DR+1) = 4*250 = 4msSec
  432.            *-----------------------------------------------------------------------------------
  433.            */
  434.         T0CR =        0x00;
  435.         T0DR =        124;        // fx/32, 32/8Mhz= 4uSec(T0DR + 1 ) = 500uSec
  436.         T0CR =0
  437.                 |(1<<7)        //0:Timer0 disable, 1:Timer0 enable
  438.                 |(0<<4)        //0:0:Timer0/counter, 1:PWM, 2:capture
  439.                 |(3<<1)        //0:fx/2, 1:fx/4, 2:fx/8, 3:fx/32, 4:fx/128, 5:fx/512, 6:fx/2048, 7:EC0
  440.                 |(1<<0)        //0:Clear Timer 0 Counter no effect, 1:Clear Timer 0 Counter auto clear
  441.                 ;
  442.        
  443.        
  444. //2013_02_01
  445. //rem out function
  446.           /*--- Set Timer1 (PWM, 38KHz, 1/3Duty for Carrier Freq.) -------------------------
  447.            * T1CR         : 0001 0010 = 0x12                        : Timer1 Control Register
  448.            * T1DRH         : 34                                                : Timer1 Data High Register
  449.            * T1DRL         : 69                                                : Timer1 Data Low  Register
  450.          * CARCR         : 0x02                                                : Carrier Control Register
  451.             * NOTE : Timer1, REMOUT, 38KHz, 1/3 or 1/2 Duty
  452.             * Time1_Int=2/8MHz*1 = 0.25uSec
  453.             * 38KHz = 26.316uSec, 1/3 Duty :
  454.             * - On_Time        = 26.316/3 = 8.772 uSec
  455.             *                    = 0.25*(T1DRH+1) = 0.25*(34+1) = 8.75
  456.             * - Off_Time         = 26.316*2/3 = 17.544 uSec
  457.             *                   = 0.25*(T1DRL+1) = 0.25*(69+1) = 17.5
  458.          *-----------------------------------------------------------------------------------
  459.            */
  460.            //fx=8Mhz老 版快
  461.         T1CR =        0x00;
  462.         T1CR =0                // fx/1, 2/8Mhz= 0.25uSec
  463.                 |(0<<7)        //0:Timer1 disable, 1:Timer1 enable
  464.                 |(0<<6)        //0:T1 Interrupt no generation, 1:T1 Interrupt generation        //6832客 促抚 !!        //org
  465.                 |(1<<4)        //0:Timer1/counter, 1:carrier
  466.                 |(1<<2)        //0:fx/1, 1:fx/2, 2:fx/4, 3:fx/8
  467.                 |(1<<1)        //0:0:temporary count stop, 1:continue count        // 犬牢窍扁 0捞搁 某府绢 臼唱咳
  468.                 |(0<<0)        //0:Counter stop, 1:Clear counter and start
  469.                 ;
  470.         /*
  471.         //fx=4Mhz老 版快
  472.         T1CR =0                // fx/1, 1/4Mhz= 0.25uSec
  473.                 |(0<<7)        //0:Timer1 disable, 1:Timer1 enable
  474.                 |(0<<6)        //0:T1 Interrupt no generation, 1:T1 Interrupt generation        //6832客 促抚 !!        //org
  475.                 |(1<<4)        //0:Timer1/counter, 1:carrier
  476.                 |(0<<2)        //0:fx/1, 1:fx/2, 2:fx/4, 3:fx/8
  477.                 |(1<<1)        //0:0:temporary count stop, 1:continue count        // 犬牢窍扁 0捞搁 某府绢 臼唱咳
  478.                 |(0<<0)        //0:Counter stop, 1:Clear counter and start
  479.                 ;
  480.         */
  481.         CARCR =0
  482.                 |(0<<4)//0:Elapsed time for low data value, 1:Elapsed time for high data value, 2:Elapsed time for low and high data values
  483.                 |(1<<1)//0:0:one-shot, 1:Repeating
  484.                 |(0<<0)//0:REM low, 1:REM high
  485.                 ;
  486.        
  487.         T1DRH =PWM_38K13D_ON;
  488.         T1DRL =PWM_38K13D_OFF;
  489.        
  490.           /*--- Set ADC(12bit) -----------------------------------------------------------------------
  491.            * ADCCRH         : 0000 0010 = 0x02                        : A/D Converter Control High Register
  492.            *  fx=4Mhz, adc_conversion_clock=4Mhz/4=1Mhz
  493.            * ADCCRL         : 0000 0010 = 0x20                        : A/D Converter Control Low Register
  494.            *-----------------------------------------------------------------------------------
  495.            */
  496.         ADCCRH =0
  497.                 |(0<<7)        //0:ADC Interrupt no generation, 1:ADC Interrupt generation
  498.                 |(0<<2)        //0:MSB align, 1:LSB align
  499.                 |(2<<0)        //0:fx/1, 1:fx/2, 2:fx/4, 3:fx/8
  500.                 ;

  501.         ADCCRL =0
  502.                 |(0<<7)        //0:ADC module disable, 1:ADC module enable
  503.                 |(0<<6)        //0:No effect, 1:ADC Conversion Start and auto cleared after conversion
  504.                 |(1<<5)        //0:Internal Reference (VDD), 1:External Reference(AVREF)
  505.                 |(0<<4)        //0:During A/D Conversion, 1:A/D Conversion finish
  506.                 |(0<<0)        //0:AN0, 1:AN1, 2:AN2, 3:AN3, 4:AN4, 5:AN5, 6:AN6, 7:AN7
  507.                 ;


  508.           /*--- Set LVI (2.2V Detection) ------------------------------------------------------
  509.            * LVICR         : 0000 0000 = 0x00                        : Low Voltage Indicator Control Register
  510.             *-----------------------------------------------------------------------------------
  511.            */
  512.         LVICR =0
  513.                 |(0<<5)        //0:Low Voltage Indicator flag No detection, 1:Low Voltage Indicator flag detection
  514.                 |(0<<4)        //0:LVI disable, 1:LVI Enable
  515.                 |(6<<0)        //0:2.00V, 1:2.10V, 2:2.20V, 3:2.32V, 4:2.44V, 5:2.59V, 6:2.75V, 7:2.93V, 8:3.14V, 9:3.38V,
  516.                 ;                //10:3.67V, 11:4.00V, 12:4.40V, 13:External Reference (LVIREF), 14:Not available, 15:Not available  

  517.         //-----------------------------------------  
  518.         //        LCD initialize
  519.         //-----------------------------------------                  
  520.           /*--- Set LCD ------------------------------------------------------------------------
  521.            * LCDCRH                : 0000 0000 = 0x00                        : LCD Driver Control High Register
  522.               * LCDCRL                : 0011 0101 = 0x35                        : LCD Driver Control Low Register
  523.               * LCDCCR                : 0000 0011 = 0x00                        : LCD Driver Contrast Control Register
  524.            * 256Hz, 1/4-Duty,1/3-Bias, Internal resistor bias mode
  525.            *-----------------------------------------------------------------------------------
  526.            */
  527.                
  528.         //Capacitor bias mode
  529.         LCDCRH =0
  530.                 |(0<<3)        //0:Not select P-Tr resistor, 1:Select P-Tr resistor 2R
  531.                 |(2<<1)        //0:Internal resistor bias, 1:External resistor bias, 2:Capacitor bias (Voltage booster)
  532.                 |(1<<0)        //0:Display off (The LCD block and voltage booster are off), 1:Normal display on(voltage booster is turn on)
  533.                 ;
  534.         LCDCRL =0
  535.                 |(3<<2)        //0:1/8Duty&1/4 bias, 1:1/6Duty&1/4 bias, 2:1/5Duty&1/3 bias, 3:1/4Duty&1/3 bias, 4:1/3Duty&1/3 bias        //org
  536.                                 //5:1/3Duty&1/2 bias(60K), 6:1/3Duty&1/2 bias, 7:1/2Duty&1/2 bias, 8:1/2Duty&1/2 bias, 9:Static
  537.                 |(1<<0)        //0:fLCD = 128Hz, 1:fLCD = 256Hz, 2:fLCD = 512Hz, 3:fLCD = 1024Hz        //org
  538.                 ;

  539.         LCDCCR =0
  540.                 |(0<<0)        //0:1.00V, 1:1.045V, 2:1.09V, 3:1.135V, 4:1.18V, 5:1.225V, 6:1.27V, 7:1.315V
  541.                 ;                //8:1.36V, 9:1.405V, 10:1.45V, 11:1.50V, 12:1.55V, 13:1.60V, 14:1.65V, 15:1.70V

  542. /*
  543.         //Internal resistor bias mode
  544.         LCDCRH =0
  545.                 |(0<<3)        //0:Not select P-Tr resistor, 1:Select P-Tr resistor 2R
  546.                 |(0<<1)        //0:Internal resistor bias, 1:External resistor bias, 2:Capacitor bias (Voltage booster)
  547.                 |(0<<0)        //0:Display off (The LCD block and voltage booster are off), 1:Normal display on(voltage booster is turn on)
  548.                 ;
  549.         LCDCRL =0
  550.                 |(3<<2)        //0:1/8Duty&1/4 bias, 1:1/6Duty&1/4 bias, 2:1/5Duty&1/3 bias, 3:1/4Duty&1/3 bias, 4:1/3Duty&1/3 bias        //org
  551.                                 //5:1/3Duty&1/2 bias(60K), 6:1/3Duty&1/2 bias, 7:1/2Duty&1/2 bias, 8:1/2Duty&1/2 bias, 9:Static
  552.                 |(1<<0)        //0:fLCD = 128Hz, 1:fLCD = 256Hz, 2:fLCD = 512Hz, 3:fLCD = 1024Hz        //org
  553.                 ;

  554.         LCDCCR =0
  555.                 |(0<<0)        //0:1.00V, 1:1.045V, 2:1.09V, 3:1.135V, 4:1.18V, 5:1.225V, 6:1.27V, 7:1.315V
  556.                 ;                //8:1.36V, 9:1.405V, 10:1.45V, 11:1.50V, 12:1.55V, 13:1.60V, 14:1.65V, 15:1.70V
  557. */               
  558.           /*--- Set Interrupt -----------------------------------------------------------------
  559.            *
  560.            *-----------------------------------------------------------------------------------
  561.            */
  562.        

  563. /*
  564. //7616A 焊靛牢 版快        
  565.         EIPOL0 =0
  566.                 |(0<<6)        //0:No interrupt at any edge, 1:extint13 Rising Edge, 2:extint13 Falling edge , 3:extint13 both Edge
  567.                 |(0<<4)        //0:No interrupt at any edge, 1:extint12 Rising Edge, 2:extint12 Falling edge , 3:extint12 both Edge
  568.                 |(0<<2)        //0:No interrupt at any edge, 1:extint10 Rising Edge, 2:extint10 Falling edge , 3:extint10 both Edge
  569.                 |(0<<0)        //0:No interrupt at any edge, 1:extint8 Rising Edge, 2:extint8 Falling edge , 3:extint8 both Edge
  570.                 ;
  571.                        
  572.         EIFLAG0 =0
  573.                 |(0<<7)        //0:T0 overflow interrupt no generation, 1:T0 overflow interrupt generation
  574.                 |(0<<6)        //0:T0 match interrupt no generation, 1:T0 match interrupt generation
  575.                 |(0<<5)        //0:Serial I/O interrupt no generation, 1:Serial I/O interrupt generation
  576.                 |(0<<3)        //0:extint13 External Interrupt not occurred, 1:extint13 External Interrupt occurred
  577.                 |(0<<2)        //0:extint12 External Interrupt not occurred, 1:extint12 External Interrupt occurred
  578.                 |(0<<1)        //0:extint10 External Interrupt not occurred, 1:extint10 External Interrupt occurred
  579.                 |(0<<0)        //0:extint8 External Interrupt not occurred, 1:extint8 External Interrupt occurred
  580.                 ;
  581.         EIPOL1H =0
  582.                 |(0<<6)        //0:No interrupt at any edge, 1:extint7 Rising Edge, 2:extint7 Falling edge , 3:extint7 both Edge
  583.                 |(0<<4)        //0:No interrupt at any edge, 1:extint6 Rising Edge, 2:extint6 Falling edge , 3:extint6 both Edge
  584.                 |(0<<2)        //0:No interrupt at any edge, 1:extint5 Rising Edge, 2:extint5 Falling edge , 3:extint5 both Edge
  585.                 |(0<<0)        //0:No interrupt at any edge, 1:extint4 Rising Edge, 2:extint4 Falling edge , 3:extint4 both Edge
  586.                 ;

  587.         EIPOL1L =0
  588.                 |(2<<6)        //0:No interrupt at any edge, 1:extint3 Rising Edge, 2:extint3 Falling edge , 3:extint3 both Edge
  589.                 |(2<<4)        //0:No interrupt at any edge, 1:extint2 Rising Edge, 2:extint2 Falling edge , 3:extint2 both Edge
  590.                 |(2<<2)        //0:No interrupt at any edge, 1:extint1 Rising Edge, 2:extint1 Falling edge , 3:extint1 both Edge
  591.                 |(2<<0)        //0:No interrupt at any edge, 1:extint0 Rising Edge, 2:extint0 Falling edge , 3:extint0 both Edge
  592.                 ;
  593.                        
  594.         EIFLAG1 =0
  595.                 |(0<<7)        //0:extint7 External Interrupt not occurred, 1:extint7 External Interrupt occurred
  596.                 |(0<<6)        //0:extint6 External Interrupt not occurred, 1:extint6 External Interrupt occurred
  597.                 |(0<<5)        //0:extint5 External Interrupt not occurred, 1:extint5 External Interrupt occurred
  598.                 |(0<<4)        //0:extint4 External Interrupt not occurred, 1:extint4 External Interrupt occurred
  599.                 |(1<<3)        //0:extint3 External Interrupt not occurred, 1:extint3 External Interrupt occurred
  600.                 |(1<<2)        //0:extint2 External Interrupt not occurred, 1:extint2 External Interrupt occurred
  601.                 |(1<<1)        //0:extint1 External Interrupt not occurred, 1:extint1 External Interrupt occurred
  602.                 |(1<<0)        //0:extint0 External Interrupt not occurred, 1:extint0 External Interrupt occurred
  603.                 ;
  604. */
  605. //7416S 焊靛牢 版快        

  606.         EIPOL0 =0
  607.                 |(2<<6)        //0:No interrupt at any edge, 1:extint13 Rising Edge, 2:extint13 Falling edge , 3:extint13 both Edge
  608.                 |(0<<4)        //0:No interrupt at any edge, 1:extint12 Rising Edge, 2:extint12 Falling edge , 3:extint12 both Edge
  609.                 |(0<<2)        //0:No interrupt at any edge, 1:extint10 Rising Edge, 2:extint10 Falling edge , 3:extint10 both Edge
  610.                 |(0<<0)        //0:No interrupt at any edge, 1:extint8 Rising Edge, 2:extint8 Falling edge , 3:extint8 both Edge
  611.                 ;
  612.                        
  613.         EIFLAG0 =0
  614.                 |(0<<7)        //0:T0 overflow interrupt no generation, 1:T0 overflow interrupt generation
  615.                 |(0<<6)        //0:T0 match interrupt no generation, 1:T0 match interrupt generation
  616.                 //|(0<<5)        //0:Serial I/O interrupt no generation, 1:Serial I/O interrupt generation
  617.                 |(1<<3)        //0:extint13 External Interrupt not occurred, 1:extint13 External Interrupt occurred
  618.                 |(0<<2)        //0:extint12 External Interrupt not occurred, 1:extint12 External Interrupt occurred
  619.                 |(0<<1)        //0:extint10 External Interrupt not occurred, 1:extint10 External Interrupt occurred
  620.                 |(0<<0)        //0:extint8 External Interrupt not occurred, 1:extint8 External Interrupt occurred
  621.                 ;
  622.         EIPOL1H =0
  623.                 |(2<<6)        //0:No interrupt at any edge, 1:extint7 Rising Edge, 2:extint7 Falling edge , 3:extint7 both Edge
  624.                 |(2<<4)        //0:No interrupt at any edge, 1:extint6 Rising Edge, 2:extint6 Falling edge , 3:extint6 both Edge
  625.                 |(0<<2)        //0:No interrupt at any edge, 1:extint5 Rising Edge, 2:extint5 Falling edge , 3:extint5 both Edge
  626.                 |(0<<0)        //0:No interrupt at any edge, 1:extint4 Rising Edge, 2:extint4 Falling edge , 3:extint4 both Edge
  627.                 ;

  628.         EIPOL1L =0
  629.                 |(0<<6)        //0:No interrupt at any edge, 1:extint3 Rising Edge, 2:extint3 Falling edge , 3:extint3 both Edge
  630.                 |(0<<4)        //0:No interrupt at any edge, 1:extint2 Rising Edge, 2:extint2 Falling edge , 3:extint2 both Edge
  631.                 |(0<<2)        //0:No interrupt at any edge, 1:extint1 Rising Edge, 2:extint1 Falling edge , 3:extint1 both Edge
  632.                 |(2<<0)        //0:No interrupt at any edge, 1:extint0 Rising Edge, 2:extint0 Falling edge , 3:extint0 both Edge
  633.                 ;
  634.                        
  635.         EIFLAG1 =0
  636.                 |(1<<7)        //0:extint7 External Interrupt not occurred, 1:extint7 External Interrupt occurred
  637.                 |(1<<6)        //0:extint6 External Interrupt not occurred, 1:extint6 External Interrupt occurred
  638.                 |(0<<5)        //0:extint5 External Interrupt not occurred, 1:extint5 External Interrupt occurred
  639.                 |(0<<4)        //0:extint4 External Interrupt not occurred, 1:extint4 External Interrupt occurred
  640.                 |(0<<3)        //0:extint3 External Interrupt not occurred, 1:extint3 External Interrupt occurred
  641.                 |(0<<2)        //0:extint2 External Interrupt not occurred, 1:extint2 External Interrupt occurred
  642.                 |(0<<1)        //0:extint1 External Interrupt not occurred, 1:extint1 External Interrupt occurred
  643.                 |(1<<0)        //0:extint0 External Interrupt not occurred, 1:extint0 External Interrupt occurred
  644.                 ;
  645.        
  646.         IE =0
  647.                 |(0<<7)        //0:All int disable, 1:All int enable
  648.                 |(0<<5)        //0:ext int0~7 disable, 1:ext int0~7 enable        // 促矫犬牢 //stop mode俊辑 enable 矫挪促.
  649.                 |(0<<3)        //0:ext int13 disable, 1:ext int13 enable
  650.                 //|(0<<2)        //0:ext int12 disable, 1:ext int12 enable        //7616A俊绰 绝澜. 0 setting!!
  651.                 //|(0<<1)        //0:ext int10 disable, 1:ext int10 enable
  652.                 //|(0<<0)        //0:ext int8 disable, 1:ext int8 enable        //7616A俊绰 绝澜. 0 setting!!
  653.                 ;

  654.         IE1 =0
  655.                 |(0<<5)        //0:SIO int disable, 1:SIO int enable                //7616A俊绰 绝澜. 0 setting!!
  656.                 |(0<<4)        //0:UART TX int disable, 1:UART TX int enable
  657.                 |(0<<3)        //0:UART RX int13 disable, 1:UART RX int13 enable
  658.                 ;
  659.                        
  660.         IE2 =0
  661.                 |(0<<4)        //0:Timer 3 match interrupt disable, 1:Timer 3 match interrupt enable
  662.                 |(0<<3)        //0:Timer 2 match interrupt disable, 1:Timer 2 match interrupt enable
  663.                 |(0<<2)        //0:Timer 1 match interrupt disable, 1:Timer 1 match interrupt enable
  664.                 |(1<<1)        //0:Timer 0 match interrupt disable, 1:Timer 0 match interrupt enable
  665.                 |(0<<0)        //0:Timer 0 overflow interrupt disable, 1:Timer 0 overflow interrupt enable
  666.                 ;

  667.         IE3 =0
  668.                 |(0<<4)        //0:BIT int disable, 1:BIT int enable
  669.                 |(0<<3)        //0:WDT int disable, 1:WDT int enable                // 犬牢
  670.                 |(1<<2)        //0:WT int disable, 1:WT int enable
  671.                 |(0<<0)        //0:ADC int disable, 1:ADC int enable
  672.                 ;
  673. #endif
  674. }

  675. //==================================================================
  676. //        Main Subroutine  
  677. //==================================================================

  678. main(void)
  679. {
  680.         int test = 0;

  681.         cli();                //nwma

  682.         Initial();                                        // start-up initialize

  683.         Lcd_Initialize();                        // LCD display off

  684.         sei();        //nwma

  685. // 2013_02_27_stop mode
  686.         //rKey_Stop        = 0;                        // 5檬 饶 Stop mode 柳涝

  687.         rKey_Stop        = 10;                        // 5檬 饶 Stop mode 柳涝
  688.        
  689.         rLcd_Mode = LCD_CLOCK;                //

  690.         while (1)                                                //
  691.         {       
  692. //w                WDTR        = 0xFF;                        // watchdog timer refresh ( 2 sec )       

  693.                 Process_Key();                        // key, ADC function  

  694.                 Process_Time();                        // Clock count up        and measurement        

  695.                 Process_Lcd();                        // LCD, LED
  696.                
  697.                 if(!(rKey_Stop))                        // 1s x n  = ?   
  698.                 {

  699.                         //clr(LCDCRH, LCD_ON);        // lcd modul disable                //lcd on 矫 20uA沥档 家葛
  700.                            //interrupt setting

  701.                         cli();
  702.                         clr(IE2, B8_1);        // Disable Timer_0 INT
  703.                         set(IE, B8_5);        // Enable  External INT 0/6/7
  704.                         set(IE, B8_3);        // Enable  External INT 13
  705.                         sei();

  706. //2013_11_21 by nakwon FLL test
  707.         clr(OSCCR, B8_2);//enable IRC

  708.         //fx=FLL 8Mhz --> 2ms 救沥拳
  709.         //FLL fx=8Mhz, bit clock 8Mhz/4096=500us, overflow period=bit clock* 4= 2ms
  710.         //P40 = 1;        //救利拳 test 侩
  711.        
  712.         BITCR=(1<<3)|(1<<0);        // BIT counter clear!!
  713.         while((BITCR&0x80)==0);        // BIT 救沥拳 2ms wait time @FLL 8Mhz
  714.        
  715.         //P40 = 0;        //救利拳 test 侩
  716.        
  717.         //
  718.         clr(SCCR, 0x03);//change FLL -> IRC
  719.         clr(FLLCR, B8_0);//disable FLL

  720.         //fx=INT_OSC 1Mhz --> 16ms 救沥拳
  721.         //internal fx=1Mhz, bit clock 1Mhz/4096=4ms, overflow period=bit clock* 4= 16ms
  722.         //P40 = 1;        //救利拳 test 侩
  723.         BITCR=(1<<3)|(1<<0);        // BIT counter clear!!
  724.         while((BITCR&0x80)==0);        // BIT 救沥拳 16ms wait time @ int_osc 1Mhz       
  725.         //P40 = 0;        //救利拳 test 侩

  726.                         //--- Enter the Stop Mode ---
  727.                         PCON = 0x03;                        // STOP Instruction Enable //wt enable/sub osc enable 矫 6uA沥档 家葛
  728.                         _nop_();
  729.                         _nop_();
  730.                         _nop_();
  731.                         _nop_();
  732.                         _nop_();
  733.                        
  734.         set(FLLCR, B8_0);//enable FLL
  735.        
  736.         //set(P6, _0000_0100);
  737.         //internal fx=1Mhz, bit clock 1Mhz/4096=4ms, overflow period=bit clock* 4= 16ms
  738.         BITCR=(1<<3)|(1<<0);        // BIT counter clear!!
  739.         while((BITCR&0x80)==0);        // BIT 救沥拳 16ms wait time @ int_osc 1Mhz
  740.         //for(test = 0; test < 0xff ;test++)
  741.         //{
  742.         //        _nop_();
  743.         //}
  744.         set(SCCR, 0x03);//change IRC -> FLL
  745.         set(OSCCR, B8_2);//disable IRC
  746.        
  747.                         _nop_();
  748. ……………………

  749. …………限于本文篇幅 余下代码请从51黑下载附件…………
复制代码

全部资料51hei下载地址:
MC96F7416S_LCD.zip (151.36 KB, 下载次数: 4)



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

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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