• slider image 442
  • slider image 483
  • slider image 484
  • slider image 485
  • slider image 486
  • slider image 487
:::


Browsing this Thread:   1 Anonymous Users






Re: 無法 從 IDLE 或 SLEEP中喚醒..救命啊~~
#4
版主
版主


查看用戶資訊
你用了 Sleep( ) 的 Marco 定義前請參考一下 h 檔裡的定義 :
#define Sleep() {__asm__ volatile ("pwrsav #0");}
#define Idle() {__asm__ volatile ("pwrsav #1");}

所以一但下了 Sleep( ) 的命令,CPU 的 FOSC 就停止振盪了,而你的Timer1 用的 Clock Source 又是Internal Source 所以連 Timer1 也停掉了,那會產生中斷叫醒 CPU ?

所以,Timer1 使用外接的震盪器並使用非同步模式;或用Idle( ) 指令只讓 CPU 停下來而Timer1 繼續執行。

發表於: 2009/12/4 12:52
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 無法 從 IDLE 或 SLEEP中喚醒..救命啊~~
#3
中級會員
中級會員


查看用戶資訊
謝謝
這就是複製貼上的缺點
拿以前的code來用
連有這個參數都不曉得
完全沒印象,因為沒用過 sleep


發表於: 2009/12/4 9:48
曾經 狂奔 舞蹈 貪婪的說話, 隨著冷的 濕的 心腐化

個人的休閒小站
歡迎來參觀
http://www.elevior.com
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 無法 從 IDLE 或 SLEEP中喚醒..救命啊~~
#2
資深會員
資深會員


查看用戶資訊
參照:

test838 寫道:
我使用的 chip 是 pic24j256gb106

我要作省電功能
我打算用 interrupt 喚醒 Idle/Sleep
但只要一下 Sleep 或 Idle 後 Interrupt 連執行都不能執行
故就不用談後續的喚醒

開了個新專案, 縮減code 如以下
我缺少什麼步驟嗎?

void Tick1Initvoid )
{
    
// Timer1 的中斷優先權設為 7,至少要比 cpu 中斷(0)高, 才可以 wake up from idle mode
    
_T1IP 7;  

    
TMR1 0;
    
PR1 TIMER_PERIOD;
    
T1CON TIMER_ON | [color=ff0000]STOP_TIMER_IN_IDLE_MODE [/color]| TIMER_SOURCE_INTERNAL |
            
GATED_TIME_DISABLED TIMER_16BIT_MODE TIMER_PRESCALER;

    
_T1IF 0;              //Clear flag
    
_T1IE 1;              //Enable interrupt
    
T1CONbits.TON 1;              //Run timer
    
}

int main()
{
    
volatile int ij;
    
    
// Disable Watch Dog Timer
    
RCONbits.SWDTEN 0;

    
Tick1Init(); // timer 1
   
    
Idle();  <-- 到這行後程式就停止執行interrupt也沒反應
    
//Sleep();
    
    
0;
    while(
1)
    {
             
j++;
                         
printf("j=%i"j);
                          
Delay_MS(1000);
    }    

}




void __attribute__((interruptshadowauto_psv)) _T1Interrupt(void)
{
    
// Clear flag
    
_T1IF 0;
    
tick++;
    
    
// 若是在 sleep mode 中, 檢查是否有按鍵, 若有喚醒
    
if (_IDLE && Key1Pressed)
    {
        
_IDLE 0// <--喚醒
    
}
    
}

發表於: 2009/12/3 18:37
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


無法 從 IDLE 或 SLEEP中喚醒..救命啊~~
#1
中級會員
中級會員


查看用戶資訊
我使用的 chip 是 pic24j256gb106

我要作省電功能
我打算用 interrupt 喚醒 Idle/Sleep
但只要一下 Sleep 或 Idle 後 Interrupt 連執行都不能執行
故就不用談後續的喚醒

開了個新專案, 縮減code 如以下
我缺少什麼步驟嗎?

void Tick1Initvoid )
{
    
// Timer1 的中斷優先權設為 7,至少要比 cpu 中斷(0)高, 才可以 wake up from idle mode
    
_T1IP 7;  

    
TMR1 0;
    
PR1 TIMER_PERIOD;
    
T1CON TIMER_ON STOP_TIMER_IN_IDLE_MODE TIMER_SOURCE_INTERNAL |
            
GATED_TIME_DISABLED TIMER_16BIT_MODE TIMER_PRESCALER;

    
_T1IF 0;              //Clear flag
    
_T1IE 1;              //Enable interrupt
    
T1CONbits.TON 1;              //Run timer
    
}

int main()
{
    
volatile int ij;
    
    
// Disable Watch Dog Timer
    
RCONbits.SWDTEN 0;

    
Tick1Init(); // timer 1
   
    
Idle();  <-- 到這行後程式就停止執行interrupt也沒反應
    
//Sleep();
    
    
0;
    while(
1)
    {
             
j++;
                         
printf("j=%i"j);
                          
Delay_MS(1000);
    }    

}




void __attribute__((interruptshadowauto_psv)) _T1Interrupt(void)
{
    
// Clear flag
    
_T1IF 0;
    
tick++;
    
    
// 若是在 sleep mode 中, 檢查是否有按鍵, 若有喚醒
    
if (_IDLE && Key1Pressed)
    {
        
_IDLE 0// <--喚醒
    
}
    
}

發表於: 2009/12/3 18:22
曾經 狂奔 舞蹈 貪婪的說話, 隨著冷的 濕的 心腐化

個人的休閒小站
歡迎來參觀
http://www.elevior.com
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部







You can view topic.
不可以 發起新主題
You cannot reply to posts.
You cannot edit your posts.
You cannot delete your posts.
You cannot add new polls.
You cannot vote in polls.
You cannot attach files to posts.
You cannot post without approval.
You cannot use topic type.
You cannot use HTML syntax.
You cannot use signature.
You cannot create PDF files.
You cannot get print page.

[進階搜尋]


:::

Microchip連結

https://www.facebook.com/microchiptechnologytaiwan/
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=13
https://mu.microchip.com/page/tmu
http://elearning.microchip.com.tw/modules/tad_link/index.php?cate_sn=1
https://page.microchip.com/APAC-PrefCenters-TW.html
http://www.microchip.com/
http://www.microchip.com/treelink
http://www.microchipdirect.com/
http://www.microchip.com.cn/newcommunity/index.php?m=Video&a=index&id=103
http://www.microchip.com.tw/modules/tad_uploader/index.php?of_cat_sn=2
http://www.microchip.com.tw/Data_CD/eLearning/index.html
http://www.microchip.com.tw/RTC/RTC_DVD/
https://www.microchip.com/development-tools/
https://www.youtube.com/user/MicrochipTechnology
[ more... ]

教育訓練中心

!開發工具購買
辦法說明 [業界客戶] [教育單位]
----------------------------------
!校園樣品申請
辦法說明 [教師資格] [學生資格]
----------------------------------