• slider image 442
  • slider image 492
  • slider image 493
  • slider image 494
  • slider image 495
  • slider image 496
  • slider image 488
  • slider image 491
:::


Browsing this Thread:   1 Anonymous Users






Re: pic18f4620 TIMER1 中斷問題
#3
資深會員
資深會員


查看用戶資訊
OpenTimer1 應該 放在 while(1) 之前 比較好吧 ?


如果 LED 是要給人看的 ;
#define TMR1_VAL 65536-16384 時間太短了吧 ( 16 mS , 以 4 M Hz X'TAL 來說 )

發表於: 2009/8/15 0:58
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: pic18f4620 TIMER1 中斷問題
#2
版主
版主


查看用戶資訊
RCON<IPEN> Interrupt Priority Control Bit 要設為 1
IPR1bits.TMR1IP=0; // Set Timer1 for Low Priority Interrupt ( Default 值為 1,設為高優先權,而你的程式卻是使用低優先權,所以中斷進不去的)。

發表於: 2009/8/14 18:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


pic18f4620 TIMER1 中斷問題
#1
新會員
新會員


查看用戶資訊
#include<p18f4620.h>
#include<timers.h>

#pragma config OSC = HS, BOREN = OFF, BORV = 2, PWRT = ON, WDT = OFF, LVP = OFF

#define TMR1_VAL 65536-16384

void Init_TMR1(void);
void timer1_isr(void);

#pragma code low_vector = 0x18

void low_interrupt(void)
{
_asm GOTO timer1_isr _endasm
}

#pragma code

#pragma interruptlow timer1_isr

void timer1_isr(void)
{
PIR1bits.TMR1IF = 0;
WriteTimer1(TMR1_VAL);
PORTD++;
}

void main(void)
{
PORTD = 0x00;
TRISD = 0;

Init_TMR1();

INTCONbits.PEIE = 1;
INTCONbits.GIE = 1;

while(1);
}

void Init_TMR1(void)
{
OpenTimer1(TIMER_INT_ON & T1_16BIT_RW & T1_SOURCE_EXT & T1_PS_1_1 & T1_OSC1EN_ON & T1_SYNC_EXT_ON );
WriteTimer1(TMR1_VAL);
PIR1bits.TMR1IF = 0;
}
//-------------------------------------------------------------------------
這是一個會讓LED所顯示的二進位數字自動加(從書上COPY下來的)
可是我用這程式下去跑都不會跑進中斷裡面
那如果我把

OpenTimer1(TIMER_INT_ON & T1_16BIT_RW & T1_SOURCE_EXT & T1_PS_1_1 & T1_OSC1EN_ON & T1_SYNC_EXT_ON );

的 T1_PS_1_1 改成 T1_PS_1_8
他就會跑進中斷

我不大懂的是~~~位啥 T1_PS_1_1 跑不進去中斷

而且就算我改成了 T1_PS_1_8 他還是指中斷一次就一直在while(1) 裡面循環 不會在計續產生中斷~~

發表於: 2009/8/13 23:37
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... ]

教育訓練中心

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