• 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: MCC18中的中断返回 为什么用return而不用retfie
#3
新會員
新會員


查看用戶資訊
多谢指点,看了资料确实如此
加了中断宣告指令,编译后为retfie返回

我原来的程序中用到了串口,A/D,timer2三个中断,主程序中只有几个nop指令。运行以后,程序并没有飞掉,是偶然看反编译指令才发现的

發表於: 2007/3/19 18:15
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: MCC18中的中断返回 为什么用return而不用retfie
#2
版主
版主


查看用戶資訊
1. 因為 0x0008 與 0x0018 的空間很小所以用 goto 將成是轉移出來到一般的程式空間處理。

2. 須用此方式宣告 :
#pragma code hi_vector=0x0008   // 設定中斷進入點
void isr_high_code(void)
{
    
_asm                 
    
goto    isr_high             
    _endasm
}             
#pragma code
//************************************************
//* Function: isr_high(void)                     *     
//*   - Received a serial data from RS-232       *
//*   - Save the received data to Rec_Data       *                  
//************************************************
#pragma interrupt isr_high 
void isr_high(void)
{
    
Rec_Data=ReadUSART();
    
PORTD=Rec_Data;
}                            
#pragma code

或用此方式宣告 Low Priority Interrupt routine :
#pragma interruptlow func-name

你的程式中對中斷宣告有錯所以被當作一般的 function 來看。
可以到這裡下載 W410 C18 講義看看第五章之說明 :
http://www.microchip.com.tw/material.htm

發表於: 2007/3/19 16:22
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


MCC18中的中断返回 为什么用return而不用retfie
#1
新會員
新會員


查看用戶資訊
用MCC18 调试PIC18F452时,发现资料中中断的格式一般如下
/****************************************/
void interrupt_at_low_vector(void)
{ _asm GOTO Interrupt_test _endasm

}
/****************************************/
void Interrupt_test(void)
{
if(PIR1bits.RCIF)
_asm goto Usart_int _endasm
if(PIR1bits.TMR2IF==1)
_asm GOTO Timer2_int _endasm
if(PIR1bits.ADIF==1)
_asm GOTO Ad_int _endasm
}
/***************************************/
void main(void)
{
..
}

void Usart_int(void)
{
}
void Timer2_int(void)
{
}
void Ad_int(void)
{
}

有两点不太明白
1。为什么中断要用goto 语句跳转到中断程序,用子程序调用不可行吗?
2。 既然用goto 语句,为什么在编译后的汇编语句中,中断返回时不是用retfie返回,而是采用 return 子程序返回语句呢


發表於: 2007/3/19 14:35
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... ]

教育訓練中心

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