以下是部分相关程序:
void interrupt ISR(void) //配置没问题,为方便看省略
void TIMER1_INITIAL (void)
{
//需要在中断里重新赋初始值
T1CON = 0B00110000; //B[5:4]=00,T2时钟分频 1:1
//B1=0,T1时钟源选择内部时钟
//T1SYNC=16M/2T=8M=0.125US
TMR1L = 0X60; //定时500US=>TMR1=4000*0.125S=500US
//初值=65536-4000=61536=>0XF060
TMR1H = 0XF0; //赋初值=>TMR1H=0XF0;TMR1L=0X60
TMR1IE = 1; //使能TMER1的中断
TMR1ON = 1; //使能TMER1启动
PEIE=1; //使能外设中断
GIE = 1; //使能全局中断
}
void BIT_F()
{
TMR1H=TMR1H_100;//10ms
TMR1L=TMR1L_100;
TMR1IF=0;
do
{
DATA_OUT=1;
}
while(!TMR1IF);
TMR1H=TMR1H_4;//0.4ms
TMR1L=TMR1L_4;
TMR1IF=0;
do
{
DATA_OUT=0;
}
while(!TMR1IF);
}
void main()
{
POWER_INITIAL(); //系统初始
TIMER1_INITIAL();
while(1)
{
BIT_F();
// PA6_Level_Change_INITIAL();
//GIE=1;
NOP();
NOP();
SLEEP(); //睡眠
NOP();
NOP();
}
}
最终运行结果发现 一直在DATA_OUT=1里面进行死循环,麻烦帮忙看下有什么问题
|