我用的是STM8S103单片机,自己编写的程序在买的最小系统板上能够正常运行,但在自己做的板子上出现问题,问题如下:刚焊接好电路板下载程序完成后单片机正常运行,但是运行经过一段时间后就无法运行了,重新上电也无法运行,甚至重新下载程序到板子上也无法继续运行,使用外部时钟和内部时钟也是一样的情况,只有用风枪吹单片机才能运行(单片机是20脚的封装,焊接应该没问题,不然一开始就无法运行了),请各位大神帮忙看看是什么问题。
while (1)
{
if (((PC_IDR&0x08)==0x00)&&(flag_stop==0))//stop signal from Hall1
{
flag_stop=1;
flag_start=0;
TIM2_CR1=0x00;//close TIME2
PB_ODR&=0xcf;//turn off LED
PD_ODR|=0x0c;//send start signal to master and open the buzzer
Delay(50);
for (i=0;i<4;i++)//send time to master
{
PD_ODR=0x08&((s/10)<<i);//4bit
Delay(50);
}
for (i=0;i<4;i++)//send time to master
{
PD_ODR=0x08&((s%10)<<i);//4bit
Delay(50);
}
PD_ODR&=0x00;//reset PD
Delay(1000);
PD_ODR|=0x20;//send control K1 to master
}
if (((PC_IDR&0x10)==0x00)&&(flag_stop==0))//stop signal from Hall2
{
flag_stop=1;
flag_start=0;
TIM2_CR1=0x00;//close TIME2
PB_ODR&=0xcf;//turn off LED
PD_ODR|=0x0c;//send start signal to master and open the buzzern
Delay(50);
for (i=0;i<4;i++)//send time to master
{
PD_ODR=0x08&((s/10)<<i);//4bit
Delay(50);
}
for (i=0;i<4;i++)//send time to master
{
PD_ODR=0x08&((s%10)<<i);//4bit
Delay(50);
}
PD_ODR&=0x00;//reset PD
Delay(1000);
PD_ODR|=0x40;//send control K2 to master
}
if ((((PC_IDR&0x08)==0x08)||((PC_IDR&0x10)==0x10))&&(flag_start==0))//start signal form Hall1 or Hall2
{
flag_stop=0;
flag_start=1;
PD_ODR&=0xf7;//reset PD3
s=0;//reset second
TIM2_CR1=0x01;//open TIME2
/**
if (s>=60)
{
s=0;
TIM2_CR1=0x00;//close TIME2
PB_ODR|=0x30;//turn on LED
PD_ODR|=0x08;//send stop signal to master
Delay(450);
}
**/
}
}
|