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


Browsing this Thread:   1 Anonymous Users






Re: PIC18F中斷問題
#3
新會員
新會員


查看用戶資訊
謝謝Beee 的解說,我會再花點時間研究一下,如果有其他問題再麻煩前輩們了,Thanks.

發表於: 2010/2/24 18:54
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: PIC18F中斷問題
#2
資深會員
資深會員


查看用戶資訊
Q1:為何我將上面的中斷向量位址0x0008 改為0x0018程式依然可以正常運作這整個程式不是設定為高優先中斷嗎?
A1-2設成 有高低中斷 不是全部為高優先中斷如某中斷之 IP 未置 1 
       
則進入 低中斷 一些重要 REGISTER 需要自行保存 恢復 )

Q2:同樣的為什麼我將 #pragma interrupt 改為 #pragma interruptlow程式依然正常運作? 
   
Timer與0x0008向量不都是設定為高優先中斷嗎?
A2看 C18 如何翻譯 由Mplab上面的 ToolBar --> View --> Program Menory  檢視
   其 Assembly 碼 
畢竟 CPU 是只執行 機械碼(組合語言)  
   
最終還是由 機械碼 決定其流程


Q3
:18F系列的中斷向量有兩個,但是中斷源有很多個,意思就是說這兩個中斷向量只能被其中兩個中斷源使用是嗎?
A3進入中斷後 自行檢查 那個中斷的 FLAG 例 TMR0IF 被設立 
     
則跳到 其相對的 中斷程式 所以兩個中斷向量 可以服務很多的中斷源


Q4
:在18F4520的 datasheet中 Figure9-1裡面有interrupt logic,裡面畫有高優先低優先中斷向量,
    
圖中只有出現Timer0,並沒有Timer1~Timer3,那是表示除了Timer0之外其他timer都不能使用這兩個中斷向量嗎
    
既然如此為何上面這範例的中斷還是可以運作?
A4那只是簡易示意圖 故沒有全部包括進去 要參考各別的章節  Interrupt 章節

發表於: 2010/2/24 9:06
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


PIC18F中斷問題
#1
新會員
新會員


查看用戶資訊
大家好

關於中斷的觀念我看了很久找些資料,還是有很多地方無法了解希望各位前輩能夠給我些意見
首先我利用C18教材EX5-2簡化了一些地方來進行測試,
目的是利用timer2中斷讓portD累加而已,檔案如下:
//************************
#include <p18cxxx.h>
#include <timers.h>
#include <delays.h>
#pragma config OSC=HS
#pragma config PWRT=OFF
#pragma config BOREN=OFF, BORV=1
#pragma config WDT=OFF
#pragma config CCP2MX=PORTC
#pragma config STVREN=OFF, LVP=OFF, DEBUG=OFF
#pragma config CPD=OFF

void isr_high(void);

volatile unsigned char Long_Count ;

void main(void)
{
TRISD=0x00;
// Set output port for LED driver
PORTD=0x00;

/***********************************/
/* Interrupt Time */
/***********************************/

RCONbits.IPEN=1; // Enable Interrupt Priority bit
IPR1bits.TMR2IP=1; // Set Timer2 for High Priority
INTCONbits.GIEH=1; // Enable High Priority Interrupt

OpenTimer2 ( TIMER_INT_ON // Turn On the Timer2 with Interrupt
& T2_PS_1_16
& T2_POST_1_10);

PR2 = 199; //8 bits value 0~255
Long_Count=0;

while(1); // Loop Here!
}

//************************************************
//* #pragma Interrupt Declarations *
//************************************************
#pragma code isrhighcode = 0x0008

void isr_high_direct(void)
{
_asm //begin in-line assembly
goto isr_high //go to isr_high function
_endasm //end in-line assembly
}
#pragma code

//************************************************
//* Function: isr_high(void) *
//************************************************
#pragma interrupt isr_high

void isr_high(void)
{
PIR1bits.TMR2IF=0; // Clear Timer2 interrupt Flag

if (Long_Count <= 12)
Long_Count++;
else
{
Long_Count=0; PORTD++ ;
}
}
#pragma code

Q1:為何我將上面的中斷向量位址0x0008 改為0x0018程式依然可以正常運作? 這整個程式不是設定為高優先中斷嗎?
Q2:同樣的為什麼我將 #pragma interrupt 改為 #pragma interruptlow程式依然正常運作? Timer與0x0008向量不都是設定為高優先中斷嗎?
Q3:18F系列的中斷向量有兩個,但是中斷源有很多個,意思就是說這兩個中斷向量只能被其中兩個中斷源使用是嗎?
Q4:在18F4520的 datasheet中 Figure9-1裡面有interrupt logic,裡面畫有高優先低優先中斷向量,圖中只有出現Timer0,並沒有Timer1~Timer3,那是表示除了Timer0之外其他timer都不能使用這兩個中斷向量嗎? 既然如此為何上面這範例的中斷還是可以運作?

問題有點多麻煩前輩提點,謝謝

發表於: 2010/2/23 23:10
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... ]

教育訓練中心

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