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

Infinite loop

Hai all,
My program goes to infinite loop even though there is no while(1);

void main()
{
        uchar8_t ISMCheckResult;
    CKCON=0x04;
        DR=1;
    delay(50000);//Power on delay for testing  purpose
                enableLatch(0x00,0,7);
                delay(40);
                readBuffer(0,7);
                ISMCheckResult=IP_Sensing_check();
                Display(ISMCheckResult);
}


It stays in following Idata Loop....

IF IDATALEN <> 0
                MOV     R0,#IDATALEN - 1
                CLR     A
IDATALOOP:      MOV     @R0,A
                DJNZ    R0,IDATALOOP
ENDIF

what is the problem?
The functions in main I have used is very simple as follows...

void enableLatch(uchar8_t lactchValue,uchar8_t start,uchar8_t end)
{
 uchar8_t index1;
 DR=0;
         for(index1=start;index1<=end;index1++)
         {
          XBYTE[latchAddressTable[index1]]=lactchValue;
         }
 DR=1;
}
void readBuffer(uchar8_t start,uchar8_t end)
{
 uchar8_t index=0;
 DR=0;
         for(index=start;index<=end;index++)
         {
                Hardware_Buffer_Value[index]=XBYTE[bufferAddressTable[index]];
         }
 DR=1;
}
uchar8_t IP_Sensing_check(void)
{
 uchar8_t  Flag=0,i;
 DR=1;
         for(i=0;i<INPUT_BUFFERS;i++)
         {
                   if(Hardware_Buffer_Value[i]!=0)
                   {
                            Failed_Latch_Location[i]=ONE;
                                Flag++;
                   }
                   else
                   {
                        Failed_Latch_Location[i]=ZERO;
                   }
         }

 return((Flag>0)?ONE:ZERO);
}
void delay(uint16_t n)
{
 uint16_t i;
 for (i=0;i<n;i++);
}
void Display(uchar8_t Input_Sensing_check_result)
{
        uchar8_t  index;
    SCON = 0x50;
    TMOD = 0x20;
        TH1  = 0xFA;
    TR1  = 1;
        TI   = 1;
        DR=1;
/*      for(index=0;index<NO_OF_LATCHES_CHECK;index++)
        {
          printf("\nBuffer Contents %2bd %2bx\n",index+1,Hardware_Buffer_Value[index]);
        }
*/
        if(Input_Sensing_check_result!=ZERO)
                {
                            printf("\nChannel checking Failed\n");

                                for(index=0;index<NO_OF_LATCHES_CHECK;index++)
                                {
                                                 if(Failed_Latch_Location[index]!=ZERO)
                                                  {
                                                   printf("\nLatch/Buffer %2bx Failed\n ", index+1);
                                                  }
                                }
                }
        else
                {
                        printf("\nChannel checking OK\n");

                }
}

The output is coming correctly but it goes to infinite loop as if while(1){ //functions} is used....what is the problem kindly clarify me..

Parents
  • Just a quick question - a program that exits main on a PC will either get back to the command line, or will have a nice GUI where you may start another program.

    What will happen when a program exits main() on an embedded device, where there is no command line? Do you expect your processor to turn off, waiting for a reset or the download of new firmware?

    By the way: Do not mix tab and space to indent your code. Spaces are better to use, since they don't rely on the viewing software (or web forum) to decide exactly how wide a tab is. Keep your code properly indented at all times.

Reply
  • Just a quick question - a program that exits main on a PC will either get back to the command line, or will have a nice GUI where you may start another program.

    What will happen when a program exits main() on an embedded device, where there is no command line? Do you expect your processor to turn off, waiting for a reset or the download of new firmware?

    By the way: Do not mix tab and space to indent your code. Spaces are better to use, since they don't rely on the viewing software (or web forum) to decide exactly how wide a tab is. Keep your code properly indented at all times.

Children
No data