why can't the Loop states and multi-dimensions arrays run?

Hi,
1. In my programme,there are some loop states such as the following:

int x,x1,x2;
x1=1;x2=100;
for(x=x1;x<=x2;x++)
{
y=k*x+b;
Pixel(x, y, Mode);
}

But in fact,the loop is executed only once,then run the wrong code and the code after the loop is never executed.can you give me some advices?
2.In my programme, there is a multi-dimension array like this--

unsigned char code HZTable[2][16]={....};

But the operation to the array always goes wrong.how can I resolve the problem?
thanks

Liu ***
huihl@163.com

Parents
  • (1) The loop itself appears to me to be ok. What does the Pixel() function do? If it is incorrect and corrupts memory, it might change the behavior of your code.

    (2) What do you mean by "the operation to the array"? You cannot write to the code memory space in an 8051. Declaring the table in code memory is appropriate if it is constant, but if you need to write the table you need to move it elsewhere (data or xdata).

Reply
  • (1) The loop itself appears to me to be ok. What does the Pixel() function do? If it is incorrect and corrupts memory, it might change the behavior of your code.

    (2) What do you mean by "the operation to the array"? You cannot write to the code memory space in an 8051. Declaring the table in code memory is appropriate if it is constant, but if you need to write the table you need to move it elsewhere (data or xdata).

Children
More questions in this forum