This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

unsigned long long problem using IAR Workbench

Other Parts Discussed in Thread: CC3200

I took ADC example and added the following lines:

uint64_t cap1,cap2;

cap1 = 2;
cap2 = (cap1 << 32) + 3;
Report("cap1 value is %llu \n\r",cap1);
Report("cap2 value is %llu \n\r",cap2);

The project is compiled without any error or warning in both CCS 6.1 and IAR workbench 7.5, the problem is that the binary compiled by IAR workbench  produces incorrect results for both variables:

cap1 value is 8589934594

cap2 value is 17179869183

CCS 6.1 compiled binary gives correct values. Any idea.

  • Another thing, the ADC readings, which are proposed to be float, are printed as very lengthily incorrect value. When adding some pieces of code or modifying some static strings, the program may sometimes run correctly.
    The only thing i suspect is stack alignment problem. Is there any solution?
    Thanks in advance.
  • As i expected, the problem is stack misalignment. When the stack pointer value is not divisible by 8 just when the main() sub is entered, the problem occurs. IAR workbench stack initialization mechanism is different from CCS. While CCS initialize the stack pointer at the end of SRAM, IAR randomly picks the initial stack pointer which is just after code segment as the map file indicate. the linker configuration file cc3200.icf CSTACK has no effect. To solve the problem, the startup_ewarm.c file is modified by adding the following directive:

    #pragma data_alignment=8
    static unsigned long pulStack[1024] @ ".noinit";
  • Another better fix is to force the linker to place pulStack array in the .stack section which is already aligned and put in CSTACK. There is a bug in either cc3200.icf or startup_ewarm.c since .noinit section is not placed in any ram region in the icf file. However, .stack section is properly placed.

    static unsigned long pulStack[1024] @ ".stack";

    the alignment directive is no more needed because CSTACK block (containing section .stack) is already aligned to 8 byte.