Part Number: TMS320F28P650DK
Dear TI Support,
We’ve found some incorrect behaviour of C generated code for f28p65x MCU. This problem reproduces on TI LaunchPad kit with F28P65x C2000 real time MCU.
The problem: the following legal C code is executed incorrectly:
float x = -10.0;
int64_t result = x / 0.1f;
On output result variable contains 0, while it should be -100 (convertion from float to integer is legal C operation until value can be fit onto integer type range)
A very simple project (may be run on launchpad for f28p65x) is attached to the ticket. When run on the launchpad (without debugger/jtag connected) it starts to blink red and green LEDs in counterphase. However if suspected code is stepped in debugger, then correct result is obtained and it starts to blink with green light only.
Some details:
1. Key compiler flags (other flags may be found in attached project properties):
--cla_support=cla2
--float_support=fpu32
-Ooff
--fp_mode=relaxed
--fp_reassoc=on
--define=DEBUG
--define=CPU1
--define=RAM
--define=generic_ram_lnk
--abi=eabi
2. Related code is executed from the RAM (it is a requirement for bootloader purposes). Convertion code (__c28xabi_ftoll) is also executed from RAM. You may see it either in attached project (built project includes assembler listing) or attached screenshots from debugger.
3. When code is executed from FLASH, problem can’t be reproduced, only when executed from RAM. When executing from RAM, reproduction rate is 100%. We tried on two kinds of f28p65x MCU: f28p650dk6pzp and f28p650dk9nmr (launchpad) - problem happens on both chips.
4. Compiler version: TI v22.6.1LTS (Linux)
CSS Studio version: 20.0.2.5_1.6.2 (Linux)
We suspect it is a compiler issue where pipeline restrictions for DIVF32 instruction are not respected.
For example: if intermidiate float variable is used after division and before conversion, problem can’t be reproduced: in this case compiler insert 4 NOP instructions (as it shown in “TMS320C28x Extended Instruction Sets Technical Reference Manual”)
However without having intermediate variable these NOP instructions are not inserted (LCR followed immediately by DIVF32 instruction).
Also, note that very first __c28xabi_ftoll instruction reads result of the division from R0H register, which seems to be not ready by this moment.
Please, consider our observations and give us some suggestion or advice how to handle or fix this problem properly correctly.
Test project: DIVF32_Test_Project.zip
Disassembled code:


Example for DIVF32 from "TMS320C28x Extended Instruction Sets Technical Reference Manual" documentation:


