• 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: dsPIC2020 TIMER1 INTERRUPT CAN NOT WORK
#2
新會員
新會員


查看用戶資訊
我有把int ISR_T1_Interrupt(void)改成void ISR_T1_Interrupt(void) 不過還是不行><

發表於: 2009/2/23 11:26
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


dsPIC2020 TIMER1 INTERRUPT CAN NOT WORK
#1
新會員
新會員


查看用戶資訊
請教一下:我想設定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
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... ]

教育訓練中心

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