由於我在程序裏定義了一個很大的數組,有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明顯減小,上述錯誤不再出現。