AnsweredAssumed Answered

Kinetis MCU bugs when using malloc and structure, go to Default ISR

Question asked by Samuel Conti on Dec 5, 2016
Latest reply on Dec 5, 2016 by Samuel Conti

Hello,

 

I use a MKL17Z256 Kinetis MCU and I have a problem with a code with dynamic allocation.

 

All is OK when I use this code :

 

typedef struct

{

       unsigned char Test_U8;

       unsigned short Test_U16;

}test_str;

 

test_str Test_STR;

test_str * PointeurTest_STR = &Test_STR;

 

PointeurTest_STR->Test_U8 = 0;

PointeurTest_STR->Test_U16 = 0;

 

But MCU buggs when I use this one:

 

typedef struct

{

     unsigned char Test_U8;

     unsigned short Test_U16;

}test_str;

 

test_str* Test_STR = malloc(sizeof(test_str));

 

Test_STR->Test_U8 = 0;

Test_STR->Test_U16 = 0;

 

The problem is the MCU fall in defaultISR in startup:MKL.....S file

 

DefaultISR:
    ldr    r0, =DefaultISR
    bx r0

 

What can cause this problem ?

Outcomes