Skip to main content
Cengizhan SAY?ILI
Associate
March 23, 2017
Question

Problem with STMicroelectronics GNU GCC compiler

  • March 23, 2017
  • 2 replies
  • 1000 views
Posted on March 23, 2017 at 09:31

Problem with STMicroelectronics GNU GCC compiler

Below partial code of our project.

typedef struct

{

    U_16 no;

    U_8 duration;

    BuzzerSounds buzzerSong;

    priorityLevels priority;

    TBOOL buzzerPeriodic;

    TBOOL isPlayed;

}event;

typedef struct

{

    U_32 canID;

    U_64 canData;

}canMSG;

typedef enum

{

    PRIORITY_BLOCKER = 0,

    PRIORITY_HIGH,

    PRIORITY_MID,

    PRIORITY_LOW,

    PRIORITY_TRIVIAL

}priorityLevels;

event eventRecord = {0,0,B_IDLE,255,0,0};

//This red part successfully compiled but not works.

static canMSG msg;

msg.canID   = CAN_ID_SETUPREAD | eventDeviceID;

msg.canData = (0x04) + (971uLL << 8) + (((U_64)eventRecord.no) << 32) + (((U_64)eventRecord.duration) << 48) + (((U_64)eventRecord.priority) << 56);

can0SendMessage(msg);

//When i changed red part of code like this, it works.

static canMSG msg;

msg.canID   = CAN_ID_SETUPREAD | eventDeviceID;

msg.canData = (0x04);

msg.canData += (971uLL << 8);

msg.canData += (((U_64)eventRecord.no) << 32);

msg.canData += (((U_64)eventRecord.duration) << 48);

msg.canData += (((U_64)eventRecord.priority) << 56);

can0SendMessage(msg);

//Also

when i changed red part of code like this, it works again

static canMSG msg;

msg.canID   = CAN_ID_SETUPREAD | eventDeviceID;

msg.canData = (0x04) + (971uLL << 8) + (((U_64)eventRecord.no) << 32) + (((U_64)eventRecord.duration) << 48);

can0SendMessage(msg);

//I think problem is enum part of code.

(((U_64)eventRecord.priority) << 56)

I compile this project with Hightec GCC 4.6.3 toolchain, there is no problem. Red part works normally.

    This topic has been closed for replies.

    2 replies

    Erwan YVIN
    ST Employee
    April 4, 2017
    Posted on April 04, 2017 at 11:08

    Hello Cenzighan ,

    The problem has been submitted in your tracker.

    In some strange cases in the free gcc compiler  (optimization issue)

    Do not hesitate to force -O0 optimization in some parts of sensitive code.

                   Best regards

                                Erwan

    Cengizhan SAY?ILI
    Associate
    April 5, 2017
    Posted on April 05, 2017 at 10:55

    Hello Erwan,

    I always use -O0 . I think problem is not optimization.

    Thanks.

    Erwan YVIN
    ST Employee
    October 12, 2017
    Posted on October 12, 2017 at 15:55

    Hello ,

    after checking the 64 bits issue ,

    No problem is noticed

    (Cf Screenshot)

    typedef struct
    {
    uint16_t no;
    uint8_t duration;
    uint16_t buzzerSong;
    uint16_t priority;
    }event;
    typedef struct
    {
    uint32_t canID;
    uint64_t canData;
    }canMSG;
    typedef enum
    {
    PRIORITY_BLOCKER = 0,
    PRIORITY_HIGH,
    PRIORITY_MID,
    PRIORITY_LOW,
    PRIORITY_TRIVIAL
    }priorityLevels;
    event eventRecord = {0,0,1,255,0,0};
    canMSG msg;
    ....
    uint32_t no=1;
    uint32_t duration = 1;
    uint32_t priority = 1;
    msg.canData = (0x04) + (971uLL << 8) + (((uint64_t)no) << 32) + (((uint64_t)duration) << 48) + (((uint64_t)priority) << 56);
    �?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?

    0690X00000608X8QAI.png

    Best regards

    Erwan