Menu

#342 Generated code not working correctly on 4.6.3

4.6.x_development
open
gcc (183)
5
2013-01-30
2013-01-30
Dan
No

Hi,
I have moved to gcc 4.6.3 recently and porting all my projects to that version.

The follwing snippet of code compiles OK on msp430-gcc 3.2.3 always.
'Always' means two different apps using the code below.
When compiled with msp430-gcc 4.6.3 one app stopped working correctly. The DRAM value was incorrectly calculated.
I guess 'const uint8 LineMap[]' array was not populated correctly ( I think it i using memcpy).

Once I added 'static' qualifier to const uint8 LineMap[] it was working OK on 4.6.3 as well.

Any idea?
Thx
Daniel

#define LCD_LINE1_ADDR 0x00
#define LCD_LINE2_ADDR 0x40
#define LCD_LINE3_ADDR 0x14
#define LCD_LINE4_ADDR 0x54
#define LCD_DDRAM_SET 0x80

void LCDSetPosition (uint8 x, uint8 y)
{
const uint8 LineMap[] =
{
LCD_LINE1_ADDR - 1,
LCD_LINE2_ADDR - 1,
LCD_LINE3_ADDR - 1,
LCD_LINE4_ADDR - 1,
};
uint8 DDRAM = LineMap[(y-1) & 0x03] + x;
DDRAM |= LCD_DDRAM_SET;
/*
* Set data address
*/
LCDCtrlWrite (DDRAM);
}

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2013-01-30

    Too little context to say. I'd need to see a standalone source file which when compiled generates clearly incorrect instructions. What you pasted could become that with the addition of <stdint.h> and a declaration of LCDCtrlWrite, if you also provide the compiler flags you use and the resulting assembly code (use -S) and explain why it's wrong.

    Otherwise the problem could be due to inlined optimization into call sites, or possibly stack corruption because the non-static version takes more memory. That it works in one program and not in another suggests the problem is not in this code alone.

     
  • Dan

    Dan - 2013-01-30

    I have to send you the whole eclipse project which consist of couple of files. I do not have luxury of time to minimize the code and make it to trigger the issue. Will objdump with -S be OK for you for working and non-working version?

    linker options msp430-gcc -mmcu=msp430f2417 -nostartfiles -mcpu=430x
    + custom linker script -Wl,-T ../ts-bootloader-msp430f2417.x

     
  • Peter A. Bigot

    Peter A. Bigot - 2013-01-30

    Nor do I have the time to extract the material from an eclipse project or reduce your test cases to isolate the problem. You can attach the objdump outputs if they're no more than a couple dozen lines each; if somebody takes over maintenance of mspgcc they may get looked at, but I won't find time for it.

     

Log in to post a comment.