This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Atmel 89c52 exit from the program after few minutes...pls help

Hello everybody..I am facing problem while am run the following program on Atmel 89c52.Actualy am running a stepper motor using STK-672-040 ,Every time i power on the circuit all working fine but after few minutes controller don't give any output and motor also not running. seems look like program exit from the
loop...pls help me.
i don't have much knowledge in controller programing but i have to make it run for my project.
#include <reg52.h>
#include <stdio.h>
#include <stdlib.h>
#include <absacc.h>
#include <string.h>
#define uchar unsigned char
#define uint unsigned int
#define T 1200
sbit M1=P2^0;
sbit M2=P2^1;
sbit M4=P2^2;
sbit M5=P2^3;
sbit EN=P2^4;
sbit CWB=P2^5;
sbit RET=P2^6;
sbit CLK=P2^7;
sbit START=P1^0;
sbit STOP=P1^1;
sbit cw=P1^2;
sbit INPUT=P1^3;
sbit STARTFLAG=P1^4;
sbit STOPFLAG=P1^5;
uchar flag,fwd,run,stp;
uchar runflag;
uint t,count,j;
void time0() interrupt 1 using 1
{ TH0 = -T/256; TL0 = -T%256; CLK = ~CLK;
} void delay(uint t)
{ uint i;
while(t--) { /* 11.0952MHZ----1ms */
for (i=0;i<256;i++) { } } }
void scan(void) {

if((EN==1)&&(STOP==1)&&(INPUT==1)&&(START==1))
{ EN=0;
TR0=0;
STOPFLAG=1;
delay(350);
STARTFLAG=1;
} else
{ }

if((EN==1)&&(START==1)&&(STOP==0)&&(INPUT==1))
{ EN=0;
TR0=0;
} else
{ }
if(STOP==0)
{ STARTFLAG=1;
} else
{

}

if((EN==0)&&(START==0)&&(runflag==1)) { stp=1; EN = 1; TH0 = -T/256; TL0 = -T%256; TR0 = 1; STARTFLAG=0;

} else {

} if((STOP==0)&&(START==0)) { runflag=0; EN=0; TR0=0; STOPFLAG=0; STARTFLAG=1;

} else { runflag=1; STOPFLAG=1; } if((INPUT==0)&&(runflag==1)&&(EN==0)) { EN = 1; TH0 = -T/256; TL0 = -T%256; TR0 = 1; }
else
{ }
if(cw==1)
{ CWB=0; }
else { CWB=1; }
}

void main()
{ TMOD = 0x01; EA = 1; ET0 = 1; M1 = 0; M2 = 0; M4 = 1; M5 = 1; EN = 0; RET = 0; CWB = 1; START = 1; STOP = 1; INPUT = 1; STOPFLAG=1; STARTFLAG=1; flag=0; runflag=1;
while(1)
{ scan();
if(START==0)
{ STARTFLAG=0;
STOPFLAG=0;
} else
{ }
delay(50);

}
}

0