Browsing this Thread:
1 Anonymous Users
Topic options
View mode
舊的在前
Re: 中斷的時間太長?
中級會員
Joined
: 2007/9/20 13:35最後登入時間
: 2008/6/27 9:38
From Taipei
Group:
註冊會員
Level : 5
HP : 0 / 114
MP : 15 / 5725
EXP : 59
謝謝Master大的指導 原來是定義的時候就有限制了
發表於: 2008/1/18 10:12
Re: 中斷的時間太長?
資深會員
Joined
: 2004/7/9 22:24最後登入時間
: 6/10 1:44
From 台灣
Group:
註冊會員
Level : 27
HP : 0 / 660
MP : 317 / 39062
EXP : 41
你原來Long_Conut的型態是unsigned char,只要改成unsigned int就可以了。
發表於: 2008/1/17 1:01
不要問我哪裡來,我只是個流浪天涯的工程師
中斷的時間太長?
中級會員
Joined
: 2007/9/20 13:35最後登入時間
: 2008/6/27 9:38
From Taipei
Group:
註冊會員
Level : 5
HP : 0 / 114
MP : 15 / 5725
EXP : 59
各位大大好, 小弟現在在研究中斷程式的寫法, 並將W401的5-2練習改寫成以下的程式: #include <p18f4550.h> #include <timers.h> #include <delays.h> #include "P18F_LCD.h" void isr_high(void); volatile unsigned char Long_Count ; volatile unsigned char Direct_LED ; volatile unsigned char Dir_Count ; void main(void) { TRISD=0x00; RCONbits.IPEN=1; IPR1bits.TMR2IP=1; INTCONbits.GIEH=1; ADCON0 = 0x01; ADCON2 = 0x25; ADCON1 |= 0x0F; OpenI2C(MASTER, SLEW_OFF); SSPADD = 59; // 100KHz and 24MHz Long_Count=0; PORTD = 0x0F; /***********************************/ /* Interrupt Time */ /*(1/(24Mhz/4)) (16*10)(199+1)) = 5.3ms */ /***********************************/ OpenTimer2 ( TIMER_INT_ON & T2_PS_1_16 & _POST_1_10); PR2 = 199; while(1); } //************************************************ //* #pragma Interrupt Declarations * //* * //* Function: isr_high_direct * //* - Direct execution to the actual * //* high-priority interrupt code. * //************************************************ #pragma code isrhighcode = 0x0008 void isr_high_direct(void) { _asm goto isr_high _endasm } #pragma code //************************************************ //* Function: isr_high(void) * //* High priority interrupt will * //* - Received a serial data from RS-232 * //* Save the received data to buffer Rec_Data* //************************************************ #pragma interrupt isr_high void isr_high(void) { PIR1bits.TMR2IF=0; if (Long_Count <= 250) Long_Count++; else { Long_Count=0; PORTD=PORTD^0xFF; } } #pragma code 預計讓high, low byte的LED每隔4秒交互亮, 可是當我更改Long_Conut超過250, 中斷程式就不會執行else裡面的程式, 請問這是因為我延遲的時間設的太久了嗎? 如果是, 我欲達到原程式設計目的, 我該怎麼修改? Oscillator : HS : HS+PLL, USB-HS DEMO Board : APP013 MCU : P18F4550 謝謝
發表於: 2008/1/16 18:38
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.