原创 单片机RAM数组溢出

2011-7-8 23:02 2930 6 6 分类: MCU/ 嵌入式

在编写输入法时,用到的一个结构数组,在结构数组中由于导入了太多的汉字导致堆栈溢出,其实就是RAM不够用了,因为程序中默认将全局的数组和变量放到RAM中去,我用的是MSP430F149它的RAM2k,还不小,但是我的汉字太多,导致2kRAM也不够了,程序如下:

struct t9PY_index

{

    unsigned char *t9PY_T9;

    unsigned char  *PY;

    unsigned char  *PY_mb;

};

struct t9PY_index  t9PY_index2[] ={{"2","a","阿啊"},

                                  {"3","e","讹俄娥峨鹅蛾额厄扼恶饿鄂遏"},

                                  {"4","i","阿啊"},

                                  {"5","l","厘梨狸"},

                                  {"6","o",""},

                                  {"7","p","阿啊"},

                                  {"8","u","阿啊"},

                                  {"9","w","阿啊"},

                                  {"22","ba","八巴叭扒吧芭疤捌跋把靶坝爸罢"},

                                           {"22","ca",""},

                                  {"23","ce","册侧厕测策"},

                                  {"24","ai","哎哀唉埃挨皑癌矮艾爱"},

                                              {"24","ci","茨瓷慈辞磁雌此次刺"},

                                  {"26","an","氨鞍俺岸按案胺暗"},

                                  {"26","ao","凹敖傲奥澳懊"},

                                          ……………………….

}

但是ROM64k啊,如果可以放到ROM中就可以解决了,然后我查了一下,发现果真可以,而且很简单,只需加个const就可以了,这样它就不会把这个分配到ROM中去调用,同时也需将调用的变量也加const,这样匹配后就可以了,问题就ok了。

PARTNER CONTENT

文章评论0条评论)

登录后参与讨论
EE直播间
更多
我要评论
0
6
关闭 站长推荐上一条 /3 下一条