由于我在程序里定义了一个很大的数组,有8192个元素,每个元素都是32位,仅该数组大小就有32768(32K)字节,而我使用的MSP430F5438A的RAM只有16KB大小。编译报告显示如下:
676 bytes of CODE memory
32784 bytes of CONST memory(+2 bytes shared)
32784 bytes of DATA memory(+34 bytes shared)
程序里德数据量太大导致RAM资源耗尽,所以最好使用const定义到FLASH里(MSP430F5438A有256KB的FLASH),问题便可解决。
定义为const之后编译报告如下:
676 bytes of CODE memory
32784 bytes of CONST memory(+2 bytes shared)
16 bytes of DATA memory(+34 bytes shared)
DATA memory明显减小,上述错误不再出现。