void main(void) {
/* put your own code here */
unsigned int direction;
//int sp;
SetBusCLK_80M();
IOC_Init();
PwmInit();
DDRA=0X00;
PUCR_PUPAE=1;
DDRB=0X00;
PUCR_PUPBE=1;
DDRE=0XFF;
PORTE=0X0C;
RTI_Init();
EnableInterrupts;
cflag=0;
sflag=0;
for(;;)
{
sensor=(unsigned int)PORTB;
sensor=sensor*16;
sensor+=(unsigned int)(PORTA&0X0F);
switch(sensor)
{
case 1: error=11;break;
case 3: error=10;break;
case 2:error=9;break;
case 6:error=8;break;
case 4:error=7;break;
case 12:error=6;break;
case 8:error=5;break;
case 24:error=4;break;
case 16:error=3;break;
case 48:error=2;break;
case 32:error=1;break;
case 96:error=0;break ;
case 64:error=-1;break;
case 192:error=-2;break;
case 128:error=-3;break;
case 384:error=-4;break;
case 256:error=-5;break;
case 768:error=-6;break;
case 512:error=-7;break;
case 1536:error=-8;break;
case 1024:error=-9;break;
case 3072:error=-10;break;
case 2048:error=-11;break;
default: error=lasterror;break;
}
if(error>=6||error<=-6)
{