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.

TMS320F28069: 字符串数组存储时浪费1个字节,能否有效压缩空间

Part Number: TMS320F28069


程序中定义文件编译时间到FLASH固定区域:

#pragma DATA_SECTION(App_Date,"AppDate");

const unsigned char App_Date[] = __DATE__" "__TIME__;

最终bin文件中效果如下图:

可以看到每1个字符实际占用了2个字节(16bits)

有没有什么技巧可以对数组进行压缩,使其占用空间减半?

在将这些信息写入Mobdus寄存器时,需要单独处理,感觉不是好方便。

/**	将程序信息存入SysReg*/
void PutInfoToSysReg(const unsigned char* infoData,Uint16 infoLength,Uint16 sysRegBase)
{
	Uint16 i = 0;
	Uint16 val = 0;
	Uint16 infoLenHalf= 0;
	infoLenHalf = infoLength / 2;
	for(i = 0;i < infoLenHalf; i++)
	{
		val = ((Uint16)*(infoData + i * 2 + 1)<<8) | *(infoData + i * 2);
		SysHolding_Set(sysRegBase + i,val);
	}
	if(infoLength % 2 != 0)
	{
		SysHolding_Set(sysRegBase + infoLenHalf,*(infoData + infoLength - 1));
	}
}

  • 额,这点好像跟数据类型有关啊,编译器里面char格式的长度的就是16-bit,而且最短的数据格式就是16-bit。

    确实有压缩空间的需要吗?确实需要的话可以去英文E2E问一下,或者我帮忙发帖也可以。