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


Browsing this Thread:   1 Anonymous Users






Re: dsp4011 產生Sine WAVE
#2
版主
版主


查看用戶資訊
Target Halt 有可能發生了 NMI (Trap) 中斷,而程式裡並沒有去處理 NMI 中斷導致程式跳回 Reset 位置執行程式而讓 ICE 停下來。建議加入Tarp 的攔截程式。
/* 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);     
}

發表於: 2008/3/21 11:11
Twitter Facebook Google Plus Linkedin Del.icio.us Digg Reddit Mr. Wong 頂部


dsp4011 產生Sine WAVE
#1
新會員
新會員


查看用戶資訊
我要寫一個PWM1會輸出SINE WAVE 的程式
程式在編譯時並沒有錯誤,但是寫入REAL ICE 執行DEBUG時 OUTPUT 卻說TARGET HALTED,請問這問題可能出在哪裡呢?
是程式的邏輯有問題?還是設定有錯誤?或者是其他的因素?
歡迎大家不吝指教


CHIP型號:DPSPIC4011
實驗版:APP009-dspic40-28p 25550110

程式碼如下:

#include <p30f4011.h>
#include <timer.h>
#include <pwm.h>
#include <math.h>

#define FCY 7372800*2
#define KPI 0.09817477 //2*PI/64
_FOSC(CSW_FSCM_OFF & XT_PLL8); //XT with 8xPLL oscillator, Failsafe clock offIRRtO
_FWDT(WDT_OFF); //Watchdog timer disabledk-
_FBORPOR(PBOR_OFF & MCLR_EN); //Brown-out reset disabled, MCLR reset enabledj{g
_FGS(CODE_PROT_OFF); //Code protect disabledw9w/

unsigned int const Timer1 = 55530;
unsigned int pwmstep = 0;
unsigned long pwmtab = 0;
unsigned long pwm_out = 0;

int dutycyclereg = 1;
unsigned long dutycycle = 0;
int updatedisable = 0;

unsigned int period = 0;
unsigned int sptime = 0x0;
unsigned int config1 = { PWM_EN &
PWM_IDLE_CON &
PWM_OP_SCALE1 &
PWM_IPCLK_SCALE1 &
PWM_MOD_FREE };
unsigned int config2 = { PWM_MOD1_COMP &
PWM_PDIS3H & PWM_PDIS2H & PWM_PEN1H
& PWM_PDIS3L & PWM_PDIS2L & PWM_PEN1L };
unsigned int config3 = { PWM_SEVOPS1 & PWM_OSYNC_PWM & PWM_UEN };
void INT_PWM(void);

void main()
{
INT_PWM();
/*INITAL TIMER1*/
ConfigIntTimer1( T1_INT_PRIOR_5
& T1_INT_OFF );
WriteTimer1( Timer1 );
/* turn on timer1 */
OpenTimer1( T1_ON
& T1_IDLE_STOP
& T1_GATE_OFF
& T1_PS_1_1
& T1_SYNC_EXT_OFF
& T1_SOURCE_INT,(FCY/1000));
period = dutycycle;
OpenMCPWM ( period, sptime, config1,config2, config3 );
}

void _ISR _T1Interrupt( void)
{
CloseTimer1();
OpenTimer1( T1_ON
& T1_IDLE_STOP
& T1_GATE_OFF
& T1_PS_1_1
& T1_SYNC_EXT_OFF
& T1_SOURCE_INT,(FCY/1000));
pwmtab = sin( KPI * pwmstep);
dutycycle = pwmtab;
SetDCMCPWM ( dutycyclereg, dutycycle,updatedisable );

if ( pwmstep < 32 ) pwmstep ++;
else pwmstep = 0 ;
}

void INT_PWM()
{
SetDCMCPWM ( dutycyclereg, dutycycle,updatedisable );


}

發表於: 2008/3/20 10:11
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... ]

教育訓練中心

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