2017-03-23 01:31 AM
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.
2017-04-04 02:08 AM
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
2017-04-05 01:55 AM
Hello Erwan,
I always use -O0 . I think problem is not optimization.
Thanks.
2017-10-12 08:55 AM
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);
�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?�?
Best regards
Erwan