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.
当我在28377D和28379D上使用long型数值时,数值经常会变成其16位的负数。然而,long型本是32位数值。一般来说,这种出错在数值较小时更容易发生。我买了很多板,这不是单一板的孤立问题。我做了个简单例子来说明我的问题:根据我的code,a的value本应该在-1和1之间来回跳动。但他却经常变为65535和-65535。这样的出错严重影响了我的使用,请TI的工程师予以协助解答,非常感谢!
代码如下:
#include "F28x_Project.h" // Device Headerfile and Examples Include File
#include "F2837xD_Ipc_drivers.h"
long a = 1;
long b= -1;
long c = 1;
void main(void)
{
InitSysCtrl();
#ifdef _STANDALONE
#ifdef _FLASH
// Send boot command to allow the CPU2 application to begin execution
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_FLASH);
#else
/*
IPCBootCPU2(C1C2_BROM_BOOTMODE_BOOT_FROM_RAM);
*/
#endif
#endif
#ifdef _FLASH
InitFlash();
#endif
InitGpio(); // Skipped for this example
DINT;
InitPieCtrl();
// Disable CPU interrupts and clear all CPU interrupt flags:
IER = 0x0000;
IFR = 0x0000;
InitPieVectTable();
EINT; // Enable Global interrupt INTM
ERTM; // Enable Global realtime interrupt DBGM
while(1)
{
if(a == 1)
{
a = b;
}
DELAY_US(1000);
if(a == -1)
{
a = c;
}
DELAY_US(1000);
}
}
请您关注
https://e2e.ti.com/support/microcontrollers/c2000-microcontrollers-group/c2000-microcontrollers---internal/f/c2000-microcontrollers---internal-forum/1010465/tms320f280045-calculation-results-abnormal
以及
我会继续关注这个帖子的。但是您提供的解决方法“”使用unsigned long“”或者“”int“”,这些方法我试验过,确实能一定程度解决,但我目前无法接受,因为我需要用到long型的正负范围,我还要用到IQmath,所以我有必要使用long型而不是其他。