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

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 Reply Children
  • the following code always goes wrong.

    void ShowHZ(unsigned char lin,unsigned char column,unsigned int hzcode)
    {
    unsigned char i;
    unsigned int StartAddr;

    StartAddr=lin*LineChar + column; //&#23450;&#20301;&#36215;&#22987;&#34892;

    for(i=0;i<16;i++)
    {
    OutPortCom3( (unsigned char)(StartAddr), (unsigned char)(StartAddr>>8), 0x24);
    OutPortCom2( HZTable[hzcode][i*2], 0xc0); //&#24038;&#21322;&#37096; &#22320;&#22336;&#21152;&#19968;
    OutPortCom2( HZTable[hzcode][i*2+1], 0xc4); //&#21491;&#21322;&#37096; &#23383;&#27169;&#22320;&#22336;&#21152;&#19968;

    StartAddr=StartAddr + LineChar;
    }
    }


    But I adapt the array operation HZTable[hzcode][i*2] and HZTable[hzcode][i*2+1] to HZTable[0][i*2] and HZTable[0][i*2]. the programme can run well.(can show the 1st double-byted word).
    why?

  • Excuse me but in your schematics 1 and 3 there is no pull up in the P0 port ??

    In the Atmel datasheet page 3 , all port have pull up EXCEPT the P0, so you may encounter sevreal problem il you doesn't put some resistors...

    Sincerely

    C.GRUN