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.

Compiler issue c2000

Other Parts Discussed in Thread: TMS320F28069

Hi,

I'm using the latest compiler, 6.4.6 for a tms320f28069. I am using optimization level 4 and have an issue with the compiled code. Consider this c code:

struct {

float inv_bus_voltage;
float cogging_gain;
} foc_command;

foc_command.inv_bus_voltage = 1.0 / foc_command.bus_voltage;
foc_command.cogging_gain = 0.0;

The generated assembly looks like this:

MOVW DP,#_foc_command+14 ; [CPU_U]
MOVB ACC,#0 ; [CPU_] |469|
.dwpsn file "../main.cpp",line 467,column 5,is_stmt,isa 0
MOV32 @_foc_command+14,R1H ; [CPU_] |467|
.dwpsn file "../main.cpp",line 466,column 5,is_stmt,isa 0
MOV32 @_foc_command+12,R0H

which then looks like this:

3f5cb9: 761F0055 MOVW DP, #0x55
3f5cbb: 0200 MOVB ACC, #0
467 foc_command.cogging_gain = 0.0;
3f5cbc: E2030100 MOV32 @0x0, R1H
466 foc_command.inv_bus_voltage = 1.0 / foc_command.bus_voltage;
3f5cbe: E203003E MOV32 @0x3e, R0H

So R0H fails to get written to the correct spot because it's on a different data page. Can this be fixed?

Update:

____________________________

At optimization level 0 and below it switches the value that it messes up.

3f605f: 761F0054 MOVW DP, #0x54
3f6061: E203003E MOV32 @0x3e, R0H
467 foc_command.cogging_gain = 0.0;
3f6063: E590 ZERO R0
3f6064: E2030000 MOV32 @0x0, R0H