• slider image 514
  • slider image 516
  • slider image 517
  • slider image 518
  • slider image 519
:::


Browsing this Thread:   2 Anonymous Users






Re: 請教有關dsPIC33FJ128MC710的問題
#3
新會員
新會員


查看用戶資訊
謝謝你的回覆!
你回覆中提到偵測NMI的程式我有從microchip網站中的例程式中複製過來
我是因為程式會跳進偵測函式的while(1)迴圈才知道有發生trap的

我會用到W14與W15是因為我現在做的題目有移植uCOS-II作業系統
所以一定會用到指令修改W14與W15的值
只是我當初有試過用簡單的程式去做背景切換沒有問題
最近換了一個稍微大一點的程式
執行一下子就會不定時的出現trap

發表於: 2007/7/9 23:25
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


Re: 請教有關dsPIC33FJ128MC710的問題
#2
版主
版主


查看用戶資訊
W14 & W15 不要用,他們是堆疊磚用的戰存器。通常在使用 dsPIC 時我會加入一段Trap的程式來偵測NMI的中斷。可以參考 dsPIC30F Peripheral Module - Internal EEPROM 的 workshop 範例。
/* Header Files */
#include "p30fxxxx.h"

/* Function Prototypes */
void _ISR _OscillatorFail(void);
void _ISR _AddressError(void);
void _ISR _StackError(void);
void _ISR _MathError(void);
void _ISR _AltOscillatorFail(void);
void _ISR _AltAddressError(void);
void _ISR _AltStackError(void);
void _ISR _AltMathError(void);


/* ************************************************************** */
/* Standard Exception Vector handlers if ALTIVT = 0, INTCON2<15> */
/* ************************************************************** */

void _ISR _OscillatorFail(void)
{

    
INTCON1bits.OSCFAIL 0;
    while(
1);     
}

void _ISR _AddressError(void)
{

    
INTCON1bits.ADDRERR 0;
    while(
1);     
}

void _ISR _StackError(void)
{

    
INTCON1bits.STKERR 0;
    while(
1);     
}

void _ISR _MathError(void)
{

    
INTCON1bits.MATHERR 0;
    while(
1);     
}


/* ************************************************************** */
/* Alternate Exception Vector handlers if ALTIVT = 1, INTCON2<15> */
/* ************************************************************** */


void _ISR _AltOscillatorFail(void)
{

    
INTCON1bits.OSCFAIL 0;
    while(
1);     
}

void _ISR _AltAddressError(void)
{

    
INTCON1bits.ADDRERR 0;
    while(
1);     
}

void _ISR _AltStackError(void)
{

    
INTCON1bits.STKERR 0;
    while(
1);     
}

void _ISR _AltMathError(void)
{

    
INTCON1bits.MATHERR 0;
    while(
1);     
}

發表於: 2007/7/9 22:29
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


請教有關dsPIC33FJ128MC710的問題
#1
新會員
新會員


查看用戶資訊
請教各位高手
我使用ICD 2在除錯時
常常發現會進入Address Error Trap和Stack Error Trap
我看過spec知道這兩個error trap發生的原因
但是我發現我的程式不是在固定的地方會發生這樣的問題
而且利用ICD 2 單步執行時常會有類似下面的情況
mov.w w0,w15
理論上應該要把w0的16位元的資料都複製到w15中
但是執行完這一指令之後
w15卻只有讀入w0的低八位元的值
高八位元的值就變成00
我在猜測是因此造成上述兩種error traps

另外想要補述一點
我的板子是自己用轉接板焊接的
不知道焊接技術不好有沒有可能造成這種問題
只是我之前用同樣的板子跑小程式都沒問題

想請問大家有沒有遇過類似的問題
是不是我哪裡忽略了
請高手賜教!謝謝!


發表於: 2007/7/9 18:03
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... ]

教育訓練中心

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