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.
Hello,
During the integration of our product, using a TMS320F28027 MCU, I encountered a bug, using the TI function _IQdiv.
When loading the program in FLASH and using it without rebooting the MCU, it works fine.
The problem occures when, after loading the program in the MCU FLASH, the device is shut down and restarted. When calling an _IQdiv function, an ILLEGAL_ISR occures during the execution of this function. If the _IQdiv function is called before the initialization of the PIE, the program goes in a trap function.
I have reproduced the problem on a TI experimenter's kit + TMS320F28027 control card, with a simplified program. The program is as follows, and only uses the IQMathLib.h, IQmath.lib, 28027_FLASH_lnk.cmd, DSP2802x_Headers_nonBIOS.cmd files available with controlsuite, and a target configuration file (xds100v1, TMS320F28027)
To reproduce the problem, compile and load the program on a TMS320F28027 target, power it down without terminating the debug session, power it up again, reconnect CCS to the target, reset and restart the program, and run it. The program should end up in a trap.
Hoping someone has a solution to this problem,
Best regards,
Adrien Thurin
The program for the bug reproduction :
#define MATH_TYPE IQ_MATH
#define GLOBAL_Q 17
#include "IQmathLib.h"
void main(void)
{
int i = 0;
_IQdiv(_IQ(.0), _IQ(4096.0));
for(;;)
{
i++;
i &= 127;
}
}
Adrien,
Does the processor get to the IQdiv function? i.e. I want to make sure the TRAP isn't a problem getting to main().
-Lori
Hello Lori,
I am a colleague of Adrien, I can confirm that the IQdiv function is reach even after the reboot. In reading the 28027_FLASH_lnk.cmd file I found the line
IQmath : > PRAML0, PAGE = 0
To my understanding this mean that the IQmath function are written in RAM by the JTAG. At the reboot the RAM is lost so is the IQdiv function code.
I have change the line to
IQmath : > FLASHA, PAGE = 0
and this seems to have solved the problem.
How ever that does not explain why the IQmpy functions have always works or that every TI's example countain that line.
Are we missing something?
Thank you in advance for your guidance.
Best regards
Emmanuel Lange
Thank you Emmanuel,
Your analysis is correct; IQmath needs to be allocated to Flash - at least for the load address - for a stand-alone (i.e. no loading of RAM through a debugger) project.
The linker files in the device_support package have this correct. It sounds like a bug in that particular linker file. I will track it down and report it to the owner - or if you could supply the directory path for the file it will help.
Regards,
Lori
Dear Lori,
Thank you very much for your insight. in fact the 28027_FLASH_lnk.cmd file have been created internally. is is based on ( 28027_RAM_lnk and 28027_IQmath_lnk ) from control suite and more importantly on the IQmath documentation (C:\TI\controlSUITE\libs\math\IQmath\v15c\doc\IQmath_v15c.pdf page 15 for piccolo ) all these documents assume that the system is not in stand alone mode this is strange expecially for the documentation that insist so much on the stand alone mode load from the bootROM.
Best regards
Em
Dear Emmanuel,
While most of IQ math library functions are true C functions, some of them are basically compiler intrinsics or macros. If you look in IQmath documentation under "C28x IQmath Library Benchmarks" you can see under column remarks how is each function realized.
What this means is that if a function is realized as an intrinsic the compiler will put replacement assembly code (without any function call) to the place of your IQmath "function". Thus the code for this is located in the same section that the C-function in which this code is write is located (most commonly in ".text" section if you did not relocate it with pragma directive).
Now the true function in IQmath library object file are mapped to "IQmath" section and it is up to you how you place it.
Regards, Mitja