|
|
View previous topic :: View next topic |
Author |
Message |
Andre Guest
|
Variables overlap with PCD 4.092 |
Posted: Fri May 08, 2009 7:41 am |
|
|
I'm using a CCS PCD 4.092 with a dsPIC33FJ256GP710.
When I call a function, the parameter variable in the called function will overlap one local variable in calling function.
Ex,
Code: | void do_check_temperature()
{
unsigned int16 value = 0;
value = 0xff;
set_module_temp_ok(true);
return value;
} |
Code: | void set_module_temp_ok(bool temp_ok)
{
temp_in_range = temp_ok;
}
|
In main.sym
8A8-8A9 do_check_temperature.value
8A8-8A9 handleSSDReq.message
8A8-8AB sendTempCounters.overtemp_cnr
8A8-8A9 handleVoltageReq.VBUS1_V
8A8-8A9 handleDaisyReq.message
8A8-8A9 handleConfigModuleReq.message
8A8-8A9 handleSetTempReportIntReq.message
8A8-8DD sendStopModuleRpy.message
8A8-8DD sendFirmwareUpgreadeRpy.message
8A8-8DD sendSimInfoMessage.message
8A8-8A9 handleSetLedWarning.message
8A8-8A9 handleSetTemplimitReq.message
8A8-8A9 handleResetModuleReq.message
8A8-8DD sendPong.message
8A8 sendFirmwareInfo.minor
8A8-8DD sendSyncReq.message
8A8-8A9 handleTempReq.temperature
8A9 set_module_temp_ok.temp_ok
What can I do about this? |
|
|
Ttelmah Guest
|
|
Posted: Fri May 08, 2009 3:14 pm |
|
|
The reason here, is that CCS, will try to re-use memory space, if a function has finished with it.
Your first function, has a void return type. CCS, does not support the 'late typed' style of void, from ANSI, but treats void as null. Therefore the compiler sees the function, as having no further use for the varable, and re-uses the space. Change the do_check_temperature declaration to int16, and the overlap should disappear.
However also study how many problems there are with the DSPIC's and CCS at present.....
Best Wishes |
|
|
Aneben Guest
|
|
Posted: Mon May 11, 2009 12:40 am |
|
|
Hi there,
Sorry, the code wasn't correct.
Consider this instead:
Code: | void do_check_temperature()
{
unsigned int16 value = 0;
value = 0xff;
set_module_temp_ok(true);
if(value = 0xff)
printf("blopp");
} |
Code: | void set_module_temp_ok(bool temp_ok)
{
temp_in_range = temp_ok;
} |
In main.sym
8A8-8A9 do_check_temperature.value
8A8-8A9 handleSSDReq.message
8A8-8AB sendTempCounters.overtemp_cnr
8A8-8A9 handleVoltageReq.VBUS1_V
8A8-8A9 handleDaisyReq.message
8A8-8A9 handleConfigModuleReq.message
8A8-8A9 handleSetTempReportIntReq.message
8A8-8DD sendStopModuleRpy.message
8A8-8DD sendFirmwareUpgreadeRpy.message
8A8-8DD sendSimInfoMessage.message
8A8-8A9 handleSetLedWarning.message
8A8-8A9 handleSetTemplimitReq.message
8A8-8A9 handleResetModuleReq.message
8A8-8DD sendPong.message
8A8 sendFirmwareInfo.minor
8A8-8DD sendSyncReq.message
8A8-8A9 handleTempReq.temperature
8A9 set_module_temp_ok.temp_ok |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon May 11, 2009 1:09 am |
|
|
should be
If the problem persists with meaningful code, it's supposed to be a PCD bug. |
|
|
Ttelmah Guest
|
|
Posted: Mon May 11, 2009 3:10 am |
|
|
What is posted, is again perfectly reasonable action.
The optimiser looks at what you are doing.
The 'temp_ok' variable, is only ever read, and in current 'C' useage, corresponds to the bottom bit of the value being passed (historically, C in the past, did a conversion from a int16, to a bit, by perfroming a logic test on the whole variable, but current - ANSI compatible _ conversion, is done by simply testing the bottom bit). Since the bit is never written, the compiler just makes the local variable map to the same place as the bottom bit of the source variable.
The optimiser is trying to minimise data movement, that is not needed.
Best Wishes |
|
|
Guest
|
|
Posted: Mon May 11, 2009 3:47 am |
|
|
Thanks for trying to help.
It seems like my examples aren't the best.
Consider this:
Code: | void do_check_temperature()
{
unsigned int16 value = 0;
//Read value from AD
value = readAD();
if(value >= 100)
set_module_temp_ok(true);
if(value < 100)
printf("Temp to high");
} |
Code: | void set_module_temp_ok(bool temp_ok)
{
temp_in_range = temp_ok;
} |
In main.sym
8A8-8A9 do_check_temperature.value
8A8-8A9 handleSSDReq.message
8A8-8AB sendTempCounters.overtemp_cnr
8A8-8A9 handleVoltageReq.VBUS1_V
8A8-8A9 handleDaisyReq.message
8A8-8A9 handleConfigModuleReq.message
8A8-8A9 handleSetTempReportIntReq.message
8A8-8DD sendStopModuleRpy.message
8A8-8DD sendFirmwareUpgreadeRpy.message
8A8-8DD sendSimInfoMessage.message
8A8-8A9 handleSetLedWarning.message
8A8-8A9 handleSetTemplimitReq.message
8A8-8A9 handleResetModuleReq.message
8A8-8DD sendPong.message
8A8 sendFirmwareInfo.minor
8A8-8DD sendSyncReq.message
8A8-8A9 handleTempReq.temperature
8A9 set_module_temp_ok.temp_ok
The readAD function will get a value from the AD that can anything between 0-4095. |
|
|
FvM
Joined: 27 Aug 2008 Posts: 2337 Location: Germany
|
|
Posted: Mon May 11, 2009 2:02 pm |
|
|
I tried to achieve a similar behaviour, but I didn't succed in overlaying do_check_temperature.value or another variable, that has to be persistent during set_module_temp_ok() execution with set_module_temp_ok.temp_ok. I also used PCD V4.092. I guess, there must be something special in your application, not visable from the shown code, a setting different from compiler default (e.g. in optimization level) or another special condition. Have you tried, to extract a minimal example from your code, that reproduces the problem?
It may be the case, that you can't reproduce it after removing part of your application, but then you possibly get insights in the conditions that are necessary to generate it. |
|
|
Guest
|
|
Posted: Tue May 12, 2009 6:09 am |
|
|
Okey, thanks for your time.
I'll try that later. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|