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

error 253

#include <reg52.h>
unsigned char chrState;
unsigned char chrDate[6];//year, month, date, hour, minute, second
unsigned char idata chrPlace;

void main()
{
unsigned char chrTemp;
do
{
do
{

}while(1);
switch (chrState)
{
case 1:
{
if (chrTemp<11)
{
switch (chrPlace)
{
case 8:
{
chrDate[0]%=10;
}
break;
case 7:
{
chrDate[0]/=10;
}
break;
case 6:
{
chrDate[1]%=10;
}
break;
case 5:
{
chrDate[1]/=10;
}
break;
case 4:
{
chrDate[2]%=10;
}
break;
case 3:
{
chrDate[2]/=10;
}
break;
case 2:
{
chrDate[3]%=10;
}
break;
case 1:
{
chrDate[3]/=10;
}
break;
case 16:
{
chrDate[4]%=10;
}
break;
case 15:
{
chrDate[4]/=10;
}
break;
case 14:
{
chrDate[5]%=10;
}
break;
case 13:
{
chrDate[5]/=10;
}
break;
default:
break;
}
}
}
break;
case 2:
{

}
break;
}
}while(1);
}

Parents
  • Please read the Notes at the top of the form where you typed your post - it tells you how to post code so that the layout is preserved.
    Please re-post the code, following the instructions - then it might be a bit more legible!

    Please also post the full text of the error message.

    The Manuals contain lists with descriptions of the error messages - have you looked at them?

Reply
  • Please read the Notes at the top of the form where you typed your post - it tells you how to post code so that the layout is preserved.
    Please re-post the code, following the instructions - then it might be a bit more legible!

    Please also post the full text of the error message.

    The Manuals contain lists with descriptions of the error messages - have you looked at them?

Children
  • You're missing some code:

    do
    {
        do
        {
    
        }while(1);
    
    ...
    

    Most of the posted sample is unreachable.

    I'd also suggest that the code might be a little more compact and readable if you set an index and an operator, so that it all collapses into

    typedef enum {Mod, Div } Operators;
    
    Operators op = SomeFunctionOfState (chrState);
    U8 i = SomeOtherFunctionOfState (chrState);
    
    if (op == Mod)
        {
        chrDate[i] %= 10;
        }
    else
        {
        chrDate[i] /= 10;
        }