在GCC中,我定义了一个结构体数组,想放到FLASH内,但编译后程序运行的时候出错,请大家帮忙看看。 typedef struct {//温度传感器表格数据结构 int Temprature; unsigned int Resistance; }Struct_TempratureTable;
Struct_TempratureTable const TempratureTable[141] PROGMEM = { {-400,65525},{-390,62555},{-380,58985},{-370,55648},{-360,52526}, {-350,49603},{-340,46865},{-330,44299},{-320,41893},{-310,39636}, {-300,37516},{-290,35525},{-280,33654},{-270,31895},{-260,30240}, {-250,28683},{-240,27216},{-230,25835},{-220,24532},{-210,23304}, {-200,22146},{-190,21052},{-180,20020},{-170,19045},{-160,18123}, {-150,17252},{-140,16428},{-130,15649},{-120,14911},{-110,14212}, {-100,13550},{-90,12923},{-80,12329},{-70,11765},{-60,11231}, {-50,10723},{-40,10242},{-30,9785},{-20,9350},{-10,8938}, {0,8545},{10,8172},{20,7818},{30,7480},{40,7159}, {50,6854},{60,6563},{70,6286},{80,6021},{90,5770}, {100,5530},{110,5301},{120,5083},{130,4875},{140,4677}, {150,4487},{160,4306},{170,4133},{180,3968},{190,3811}, {200,3660},{210,3516},{220,3378},{230,3247},{240,3121}, {250,3000},{260,2886},{270,2776},{280,2672},{290,2571}, {300,2476},{310,2384},{320,2296},{330,2211},{340,2130}, {350,2053},{360,1979},{370,1908},{380,1839},{390,1774}, {400,1711},{410,1651},{420,1593},{430,1537},{440,1484}, }; 运算的程序是 int CalculateTemprature(unsigned int ResistanceValue) { unsigned char i; int Temprature; for(i=0;i<141;i++) { if(ResistanceValue>=TempratureTable.Resistance) { break; } } Temprature=TempratureTable.Temprature; Temprature=Temprature -(ResistanceValue-TempratureTable.Resistance)*10 /(TempratureTable[i-1].Resistance-TempratureTable.Resistance); return(Temprature); } 程序运行的时候得出的温度是乱的,难道定义在FLASH里的数组不能直接用吗?或者说用的时候还要考到RAM中才能用吗? |