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

3d array acces bug

Hello!

I declared 3d array in my Keil project for lpc1788: volatile uint16_t db[16][128][3]. When I read members of the array db[x][y][z] with z < 1 there is no problem. But if I try to read members with z >=1 I always get 0xFFFF, even if they are not equal 0xFFFF (I checked it in debugger). For example:

db[0][1][0] = 0x1515;
uint16_t id_ = db[0][1][0];       //works fine, id_ is equal 0x1515

db[1][0][1] = 0x1515;
uint16_t index_ = db[1][0][1];    //returns index_ equal 0xFFFF


Could anybody explain to me what's wrong?

Regars, Vasilij.

Parents
  • I've tried this:

            volatile short db[16][128][3];
    
    int main (void)
    {
            short test;
    
            db[0][1][0] = 0x1515;
            test=db[0][1][0];
            db[1][0][1] = 0x2525;
            test=db[1][0][1];
    }
    

    and it works as supposed. Toolset was V4.50

    Beware that some other part of your code (e.g.interrupt service routine)
    might erroneously overwrite that 3D array...

    - Dejan

Reply
  • I've tried this:

            volatile short db[16][128][3];
    
    int main (void)
    {
            short test;
    
            db[0][1][0] = 0x1515;
            test=db[0][1][0];
            db[1][0][1] = 0x2525;
            test=db[1][0][1];
    }
    

    and it works as supposed. Toolset was V4.50

    Beware that some other part of your code (e.g.interrupt service routine)
    might erroneously overwrite that 3D array...

    - Dejan

Children