Topic : ST7 - STM8 Compiler Crash

Forum : ST7/STM8

Original Post
Post Information Post
July 6, 2009 - 11:00pm
Guest

Hi,

We're using a REva starter kit with:
- a REva motherboard v3.3 with RLink
- a REva STM8S208RB daughter board.
- Windows XP, Service Pack 2

We're programming the SMT8S208RB chip using Ride7 and the RLink connector. The compiler is registered so we should be able to build 16kB binaries.

All the REva examples provided build and run fine and we've written several of our own programs that build and run on the Eval board ok as well. However, we have one program that fails to build without giving any compiler or linker error messages - it looks like the compiler just crashes during the build and we get a message from Windows that says:

"ST7-STM8 C compiler has encountered an error and has to close."

Without any error messages from the compiler or linker it's a pretty difficult problem to debug. At first we thought it could be a file size problem - if we remove a small amount of code the program compiles and runs fine. Although this seems strange since we are nowhere near our 16kB limit.

There might also be a clue in the code we need to remove for the build to succeed. Below is a segment of the program. When the while loop is included as written, the compiler crashes. When we remove some of the else-if statements that have no commands inside e.g.

else if ((u8)(_RxMessage.Data[0]) == COMMAND_RC){

}

then the build works.

We've finally come to the conclusion that it is a problem with the compiler optimisation level. Again, if we include the while loop as written and reduce the compiler optimisation level from 3 to 2 then the build is successful.

Is there an obvious problem with these else-if statements that we've missed? What is the compiler optimisation trying to do with them? And would you expect the compiler to have a more graceful exit than just crashing?

Or could it be something other than compiler optimization that's causing the compiler crash??

Cheers
Claire

Problematic code:

while( ( CAN_MessagePending() ) < 1 );

CAN_Receive(&_RxMessage);

//Enter powerdown
if ((u8)(_RxMessage.Data[0]) == COMMAND_PD){

}

//Read ADC
else if ((u8)(_RxMessage.Data[0]) == COMMAND_ADC){
if ((u8)(_RxMessage.Data[1]) == 03){

//IO: ADC
Config_ADC_POT();

/*Get conversion value*/
conversionValue = ADC2_GetConversionValue();

/*Display conversion value on LCD*/
sprintf(LCD_str,"conversion value is %u",conversionValue);
LCD_Display_string(LCD_str);

/*Send CAN message*/
//transmitMailbox = CAN_SendData(COMMAND_ADC,0,conversionValue,0,0,0,0,0);
TxBoardID[0] = COMMAND_ADC;
TxBoardID[2] = conversionValue;
transmitMailbox = CAN_SendData(&TxBoardID[0]);

ADC2_DeInit();
}
else if ((u8)(_RxMessage.Data[1]) == 01){

//IO: ADC
Config_ADC_INP1();

/*Get conversion value*/
conversionValue = ADC2_GetConversionValue();

/*Display conversion value on LCD*/
sprintf(LCD_str,"conversion value is %u",conversionValue);
LCD_Display_string(LCD_str);

/*Send CAN message*/
//transmitMailbox = CAN_SendData(COMMAND_ADC,0,conversionValue,0,0,0,0,0);
TxBoardID[0] = COMMAND_ADC;
TxBoardID[2] = conversionValue;
transmitMailbox = CAN_SendData(&TxBoardID[0]);

ADC2_DeInit();
}
}

//Set DAC
else if ((u8)(_RxMessage.Data[0]) == COMMAND_DAC){

//setHV();
}

//Start In-Application programming
else if ((u8)(_RxMessage.Data[0]) == COMMAND_IAP){

}

//Fires test pulser
else if ((u8)(_RxMessage.Data[0]) == COMMAND_TP){

}

//Set row and column address
else if ((u8)(_RxMessage.Data[0]) == COMMAND_RC){

}

//Enable or disable HV bits
else if ((u8)(_RxMessage.Data[0]) == COMMAND_HV){

//enableHV();
}

//Return board ID
else if ((u8)(_RxMessage.Data[0]) == COMMAND_ID){

SendID();
}

//Turn on either red or green LED
else if ((u8)(_RxMessage.Data[0]) == COMMAND_LED){

}

//Return version number
else if ((u8)(_RxMessage.Data[0]) == COMMAND_VER){

}

}

Replies
Post Information Post
+1
0
-1
July 7, 2009 - 9:40am
Raisonance Support Team

Hi Clairet,

This issue has already been reported, and is fixed in the latest version of the compiler.
Please download the update from http://www.mcu-raisonance.com/mcu_downloads.html.

Let us know if this fixes your problem.
Regards,
Bruno

+1
0
-1
July 9, 2009 - 9:27pm
Guest

Hi Bruno,

I downloaded and installed the latest versions of Ride7 and RKit-STM8 and I'm afraid I still see the same problem - setting the optimisation level to 3 causes the compiler to crash.

Is there anything else I should try?

Cheers
Claire

+1
0
-1
July 30, 2009 - 11:20am
Raisonance Support Team

Did you try version 2.22.09.0203 from July, 24th?

Stéphane

+1
0
-1
September 1, 2009 - 12:39am
Guest

Hi Stephane,

Sorry for the long delay in replying - I've been on vacation.

I've just tried Ride7 version 2.22.09.0203 (along with RKit-STM8 version 2.24.09.0238). My build still fails when I use optimization level 3, however, the compiler no longer crashes - I now get this compiler error message:

*** FATAL ERROR C041 IN LINE 30 OF C:\ProgramFiles\Raisonance\Ride\Examples\STM8\REva\STM8S208RB\proto_firmware\read_ID.c : (null) (00,00,00,00,00,00,28)

Again, the build is successful if I use optimization level 2 or 1.

Cheers
Claire

+1
0
-1
September 1, 2009 - 10:03am
Raisonance Support Team

Hi Claire,

We just recompiled the whole project you sent us early July: Everything goes fine with the latest tools Ride7-7.2.09.203 and RKit-STM8-2.24.09.0238, no problem at all on 2 different machines in both speed and size optimization modes.

It looks like the problem you encounter is different from the one we fixed one month earlier, as it was in your "CAN_message.c" file, and the new problem is in read_ID.c.

Can you send us a copy of your failing project so that we can fix this?

Thanks,
Bruno