AnsweredAssumed Answered

Passing 2D array to a function - Hard Falt when reading it

Question asked by Anthony Duhamel Employee on Dec 11, 2015
Latest reply on Dec 15, 2015 by Anthony Duhamel

Hello,

 

I'm coding on a KL46Z Mcu, using CW10.6/PEx IDE plus MQXLite and I have some troubles with double pointer accesses. In fact I'm passing a 2D array to a function. When I read the double pointer value, there is a Cpu Hard Fault.

 

Basically my function is:

 

vMyClass_MyFunction(int16_t** __aai16_Buffer,uint8_t __u8_BufferLength)
{
     int16_t __i16_test;
     uint16_t __u16_i;

     for(__u16_i=0;__u16_i<__u8_BufferLength ;__u16_i++)
       {
               //__i16_test= __aai16_Buffer[0][__u16_i];  // Hardfault when uncommented
               if(  __aai16_Buffer[0][__u16_i]!=0 && __aai16_Buffer[1][__u16_i]!=0) // hard fault here
               {
                    // do something
               }

        }   
}

 

Called by:

static int16_t _aai16_globalBuffer[2][100];
vMyClass_MyFunction(_aai16_globalBuffer, 100);

 

This function worked in an other project. Maybe there is an option to tick or enable to allow those kind of access in my project.

 

Does anybody have an answer to fix that?

 

Thanks!

 

Anthony

Outcomes