Browsing this Thread:
1 Anonymous Users
|
Re: dsPIC2020 TIMER1 INTERRUPT CAN NOT WORK
|
|
新會員
Joined
: 2009/2/18 23:20 最後登入時間
: 2009/6/15 15:02
Group:
註冊會員
Level : 1 HP : 0 / 15 MP : 2 / 688 EXP : 60
|
我有把int ISR_T1_Interrupt(void)改成void ISR_T1_Interrupt(void) 不過還是不行><
發表於: 2009/2/23 11:26
|
|
|
dsPIC2020 TIMER1 INTERRUPT CAN NOT WORK
|
|
新會員
Joined
: 2009/2/18 23:20 最後登入時間
: 2009/6/15 15:02
Group:
註冊會員
Level : 1 HP : 0 / 15 MP : 2 / 688 EXP : 60
|
請教一下:我想設定TIMER1的中斷功能並且每1ms進入中斷副程式執行。初始化時timer1相關暫存器我都有開啟(如t1_on, t1_int_enable, ti_pripr7, )並且清除t1的專斷旗標。但是不巧的是他初始化完就一直於主程式迴圈裡並不會因timer1計數1ms就進入中斷副程式。我不曉得是我站存器少設了什麼還是要有特別的指令去呼叫持是過來執行中斷副程式,我是只用c language. 麻煩你了^^
#define __dsPIC30F2020__ #include <p30F2020.h> #include <timer.h> #define FCY 424628450/32 //CLK/8/4
void Init_TMR1(void);
unsigned char second = 0; unsigned char onesecond = 0; unsigned int milisec = 0;
int ISR_T1_Interrupt(void) { milisec = milisec+1 ; if(milisec == 1000) { milisec = 0; onesecond = 1; } IFS0bits.T1IF = 0; }
int main(void) { ADPCFG = 0XFFFF; TRISB = 0X0000;
Init_TMR1(); onesecond = 0; while(1) { if(onesecond) { onesecond = 0; second = second+1; LATB = second; } }
}
void Init_TMR1(void) { IEC0bits.T1IE = 1 ;//Enable the interrupt function IFS0bits.T1IF = 0 ;//Clear the interrupt flag for initial setting IPC0 = 0x7000 ; //The highest Priority level 7 PR1 = FCY/1000 ; //Calculate the FCY with 1m Sec T1CON = 0x8000 ; //Turn on timer1, prescale 1:1 }
發表於: 2009/2/23 11:25
|
|
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.