OSDN Git Service

[IDLE] Enable idle-mode before kicking tmr0.
authorK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 10 Jun 2013 20:38:50 +0000 (05:38 +0900)
committerK.Ohta <whatisthis.sowhat@gmail.com>
Mon, 10 Jun 2013 20:38:50 +0000 (05:38 +0900)
idle.c

diff --git a/idle.c b/idle.c
index 7e42613..b944d77 100644 (file)
--- a/idle.c
+++ b/idle.c
@@ -30,6 +30,11 @@ void idle(unsigned int initial)
    unsigned char osccon;
    unsigned char  contword;
 
+   /* Enable IDLE */
+   osccon = OSCCON;
+   osccon = osccon | _IDLEN |  _SCS1 | _SCS0;
+   OSCCON = osccon;
+   
    /* Set TMR0 for interrupt*/
    /* Pre-scaler: 1/16, PSA=0(ON), TOSE=0, T0CS=0(INTERNAL), T08BIT=1(8bit), TMR0ON=1(START) */
    contword = _T0PS0 | _T0PS1 | _T08BIT | _TMR0ON; // _T0PS2
@@ -37,8 +42,5 @@ void idle(unsigned int initial)
    TMR0L = initial & 0xff;
    T0CON = contword;
    
-   osccon = OSCCON;
-   osccon = osccon | _IDLEN |  _SCS1 | _SCS0;
-   OSCCON = osccon;
    Sleep();
 }