This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TM4C1290NCPDT: float alignment TI Compiler

Part Number: TM4C1290NCPDT


Hi,

I'm using the ti-cgt-arm Toolchain, currently 18.12.6, but I checked also latest Version 20 and 16.

The code below causes a FaultISR, at the assignment: tPointer->fWert=1.0;

I think, this is something with the alignment (see the +1 at the auPool), as if I use e.g.+4 there's no problem.

typedef struct SEreignisdaten
{
    int16_t iDaten;                    
    uint8_t eDatenTyp;            
    float   fWert;                
    uint8_t eBedienung;
} tEreignisdaten;

int main(void)
{
    uint8_t auPool[100]; 
    tEreignisdaten *tPointer=(tEreignisdaten *)((uint8_t*)&auPool+1);
    tPointer->fWert=1.0;
    ...
}

I've found a workaround, but I wonder if this is somehting to be fixed in the future or if there is a compilerflag or something.

Thanks for your comments

Regards

Micky

  • When you write this code ...

    (tEreignisdaten *) expression

    you take on the responsibility to insure that the expression is aligned as required by the pointer to the structure.  In this specific case, there is no guarantee that 

    uint8_t auPool[100];

    is aligned on any particular address boundary.  Thus, there is no way to guarantee that any expression which uses the address of auPool will be aligned on any particular address boundary.

    Thanks and regards,

    -George

  • Hi George,

    thanks for your answer. This was my guess. Anyway, with a gcc and the same file, I didnot encounter this problem. I'm not a compiler specialist, so I'm not sure, if this is more a problem on my site or on the compiler.

    Regards

    Micky