大家好
我是dspic的新手
我是用dspic 4011
板子是app009
程式是用修改MC LV Lab2的程式
#include "p30F4011.h"
#define FCY 10000000
#define MILLISEC FCY/10000
#define S9 PORTBbits.RB6
unsigned char SSTIndex = 0;
void DelayNmSec(unsigned int N);
void InitTMR1(void);
const unsigned int SixStepTable[] =
{0x0016, 0x0014 };
void __attribute__((__interrupt__)) _T1Interrupt(void)
{
IFS0bits.T1IF = 0;
OVDCON = (int)SixStepTable[SSTIndex++];
if (SSTIndex == 2)
SSTIndex = 0;
return;
}
int main(void)
{
ADPCFG = 0xFFF8;
PWMCON1 = 0x0F77;
PTCONbits.PTEN = 1;
InitTMR1();
for(;; )
{
OVDCON = 0;
while (S9);
DelayNmSec(30);
while (!S9);
DelayNmSec(30);
T1CONbits.TON = 1; // turn on T1
while (S9);
DelayNmSec(30);
while (!S9);
DelayNmSec(30);
T1CONbits.TON = 0;
}
return ;
}
void DelayNmSec(unsigned int N)
{
unsigned int j;
while(N--)
for(j=0;j < MILLISEC;j++);
return;
}
void InitTMR1(void)
{
TMR1 = 0x0000;
PR1 = 65535;
T1CON = 0x0000;
IFS0bits.T1IF = 0;
IEC0bits.T1IE = 1;
return;
}
按下按鈕 執行大約15妙後
就會停止
請問各位先進們
是程式的問題
還是電路板的不一樣所造成的
我該怎麼解決
先謝各位
Edited by Ryang on 2008年09月10日 08:28:07