共2条
1/1 1 跳转至页
问
prog_char StrLength[396]={4,26,18,6,18,34,16,30,24,36,
30,10,12,46,24,8,8,12,18,40,
20,2,22,14,10,10,10,6,24,6,
20,24,20,12,20,30,30,10,24,
34,2,14,10,10,14,2,24,12,2,
8,6,16,6,12,12,24,30,10,24,
6,14,36,32,16,14,18,2,20,16,
28,12,8,16,24,26,2,16,16,34,
22,24,30,30,2,2,88,4,12,22,
18,20,34,2,4,14,30,18,36,12,
6,22,6,32,6,12,4,14,38,6,18,
34,4,8,10,18,14,36,18,10,28,
28,42,12,20,108,36,78,26,56,
50,40,50,4,34,52,14,18,22,6,
10,14,14,8,30,8,4,8,8,14,10,
8,4,16,22,8,8,14,6,30,14,18,
6,22,6,68,28,24,24,10,24,28,
22,18,12,40,12,4,14,24,28,18,
12,18,12,24,2,32,6,16,28,18,
16,4,12,12,2,36,6,30,14,10,6,
2,10,2,4,2,2,22,14,4,4,14,2,
12,8,8,6,2,4,8,2,2,14,14,12,
16,10,14,18,4,28,36,8,8,4,10,
18,16,2,30,72,6,44,16,30,10,
22,26,4,16,26,22,16,4,8,10,
6,4,20,4,2,20,6,20,4,6,4,4,
6,8,8,6,8,6,2,2,18,4,34,16,22,
24,34,22,96,20,66,4,8,4,6,8,8,
8,30,16,8,22,6,22,6,16,18,18,36,
26,22,2,8,30,16,12,6,20,26,8,22,
4,12,8,22,14,4,34,20,66,20,6,18,
58,68,24,54,40,34,40,20,28,14,20,
38,20,14,28,32,66,34,34,30,106,32,
36,2,30,40,88,40,18,24,8,16,8,6,
28,8,2,2,6,26,14,34,32,22,22,34,
28,86,22,28,52,2,2,10,16,12,4,
20,28,14,8,16,6,8,4,14};
mLatterIndex=1;
set_lcd_xy(100,100);
sl=StrLength[mLatterIndex];
Disp_Int(sl,3);
set_lcd_xy(200,100);
sl=StrLength[1];
Disp_Int(sl,3);
不知为什么,对于StrLength这个数组,以上两种调用方式得到的结果不一样,不知为什么,这个数组在FLASH里面.请高手指教,急急急. 答 1: 结果分别是:243和26 答 2: 好象不能这样调用吧要用专门的命令,我不记得了,要找找资料 答 3: lornboat兄,帮找一下,谢谢. 答 4: 看AVR-LIB文档读取FLASH里的数据有专门的宏。 答 5: 用pgm_read_byte()函数
用pgm_read_byte()函数,必须包括头文件“AVR/pgmspace.h"。
以下是一段程序,希望对你有用:
#include "AVR/io.h"
#include "AVR/pgmspace.h"
char mLatterIndex;
char sl;
char sll;
const char StrLength[] PROGMEM={4,26,18,6,18,34,16,30,24,36,
30,10,12,46,24,8,8,12,18,40,
20,2,22,14,10,10,10,6,24,6,
20,24,20,12,20,30,30,10,24,
34,2,14,10,10,14,2,24,12,2,
8,6,16,6,12,12,24,30,10,24,
6,14,36,32,16,14,18,2,20,16,
28,12,8,16,24,26,2,16,16,34,
22,24,30,30,2,2,88,4,12,22,
18,20,34,2,4,14,30,18,36,12,
6,22,6,32,6,12,4,14,38,6,18,
34,4,8,10,18,14,36,18,10,28,
28,42,12,20,108,36,78,26,56,
50,40,50,4,34,52,14,18,22,6,
10,14,14,8,30,8,4,8,8,14,10,
8,4,16,22,8,8,14,6,30,14,18,
6,22,6,68,28,24,24,10,24,28,
22,18,12,40,12,4,14,24,28,18,
12,18,12,24,2,32,6,16,28,18,
16,4,12,12,2,36,6,30,14,10,6,
2,10,2,4,2,2,22,14,4,4,14,2,
12,8,8,6,2,4,8,2,2,14,14,12,
16,10,14,18,4,28,36,8,8,4,10,
18,16,2,30,72,6,44,16,30,10,
22,26,4,16,26,22,16,4,8,10,
6,4,20,4,2,20,6,20,4,6,4,4,
6,8,8,6,8,6,2,2,18,4,34,16,22,
24,34,22,96,20,66,4,8,4,6,8,8,
8,30,16,8,22,6,22,6,16,18,18,36,
26,22,2,8,30,16,12,6,20,26,8,22,
4,12,8,22,14,4,34,20,66,20,6,18,
58,68,24,54,40,34,40,20,28,14,20,
38,20,14,28,32,66,34,34,30,106,32,
36,2,30,40,88,40,18,24,8,16,8,6,
28,8,2,2,6,26,14,34,32,22,22,34,
28,86,22,28,52,2,2,10,16,12,4,
20,28,14,8,16,6,8,4,14};
void main(void)
{
mLatterIndex=1;
//set_lcd_xy(100,100);
sl=pgm_read_byte(&StrLength[mLatterIndex]);//pgm_read_byte(address short)
//Disp_Int(sl,3);
//set_lcd_xy(200,100);
sll=pgm_read_byte(&StrLength[1]);
// Disp_Int(sl,3);
}
答 6: 谢谢lee_t_1000谢谢lee_t_1000大哥,你解决了我n天未解决的问题,谢谢!!! 答 7: 我用的是PRG_RDB这个宏,问题解决了但又有一个新的问题:
#include <AVR/pgmspace.h>
const char foo[] PROGMEM = "Foo";
const char bar[] PROGMEM = "Bar";
PGM_P array[2] PROGMEM = {
foo,
bar
};
int main (void)
{
char buf[32];
strcpy_P (buf, array[1]);
return 0;
}
这是LIB文档上的例子,变量为PGM_P指针形的,这时如果将其中的array[1]改为
i=1;
array[i];
同样读取的数据不对,这个如何解决.请教高手. 答 8: 请问请问const char StrLength[] PROGMEM={4,26,18,6,18,34,16,30,24,36,、、、、}
这段数组是否是存在flash还是rom里还是每次都有程序调到ram里啊? 答 9: 就是在Flash里,是一组常数,死的
30,10,12,46,24,8,8,12,18,40,
20,2,22,14,10,10,10,6,24,6,
20,24,20,12,20,30,30,10,24,
34,2,14,10,10,14,2,24,12,2,
8,6,16,6,12,12,24,30,10,24,
6,14,36,32,16,14,18,2,20,16,
28,12,8,16,24,26,2,16,16,34,
22,24,30,30,2,2,88,4,12,22,
18,20,34,2,4,14,30,18,36,12,
6,22,6,32,6,12,4,14,38,6,18,
34,4,8,10,18,14,36,18,10,28,
28,42,12,20,108,36,78,26,56,
50,40,50,4,34,52,14,18,22,6,
10,14,14,8,30,8,4,8,8,14,10,
8,4,16,22,8,8,14,6,30,14,18,
6,22,6,68,28,24,24,10,24,28,
22,18,12,40,12,4,14,24,28,18,
12,18,12,24,2,32,6,16,28,18,
16,4,12,12,2,36,6,30,14,10,6,
2,10,2,4,2,2,22,14,4,4,14,2,
12,8,8,6,2,4,8,2,2,14,14,12,
16,10,14,18,4,28,36,8,8,4,10,
18,16,2,30,72,6,44,16,30,10,
22,26,4,16,26,22,16,4,8,10,
6,4,20,4,2,20,6,20,4,6,4,4,
6,8,8,6,8,6,2,2,18,4,34,16,22,
24,34,22,96,20,66,4,8,4,6,8,8,
8,30,16,8,22,6,22,6,16,18,18,36,
26,22,2,8,30,16,12,6,20,26,8,22,
4,12,8,22,14,4,34,20,66,20,6,18,
58,68,24,54,40,34,40,20,28,14,20,
38,20,14,28,32,66,34,34,30,106,32,
36,2,30,40,88,40,18,24,8,16,8,6,
28,8,2,2,6,26,14,34,32,22,22,34,
28,86,22,28,52,2,2,10,16,12,4,
20,28,14,8,16,6,8,4,14};
mLatterIndex=1;
set_lcd_xy(100,100);
sl=StrLength[mLatterIndex];
Disp_Int(sl,3);
set_lcd_xy(200,100);
sl=StrLength[1];
Disp_Int(sl,3);
不知为什么,对于StrLength这个数组,以上两种调用方式得到的结果不一样,不知为什么,这个数组在FLASH里面.请高手指教,急急急. 答 1: 结果分别是:243和26 答 2: 好象不能这样调用吧要用专门的命令,我不记得了,要找找资料 答 3: lornboat兄,帮找一下,谢谢. 答 4: 看AVR-LIB文档读取FLASH里的数据有专门的宏。 答 5: 用pgm_read_byte()函数
用pgm_read_byte()函数,必须包括头文件“AVR/pgmspace.h"。
以下是一段程序,希望对你有用:
#include "AVR/io.h"
#include "AVR/pgmspace.h"
char mLatterIndex;
char sl;
char sll;
const char StrLength[] PROGMEM={4,26,18,6,18,34,16,30,24,36,
30,10,12,46,24,8,8,12,18,40,
20,2,22,14,10,10,10,6,24,6,
20,24,20,12,20,30,30,10,24,
34,2,14,10,10,14,2,24,12,2,
8,6,16,6,12,12,24,30,10,24,
6,14,36,32,16,14,18,2,20,16,
28,12,8,16,24,26,2,16,16,34,
22,24,30,30,2,2,88,4,12,22,
18,20,34,2,4,14,30,18,36,12,
6,22,6,32,6,12,4,14,38,6,18,
34,4,8,10,18,14,36,18,10,28,
28,42,12,20,108,36,78,26,56,
50,40,50,4,34,52,14,18,22,6,
10,14,14,8,30,8,4,8,8,14,10,
8,4,16,22,8,8,14,6,30,14,18,
6,22,6,68,28,24,24,10,24,28,
22,18,12,40,12,4,14,24,28,18,
12,18,12,24,2,32,6,16,28,18,
16,4,12,12,2,36,6,30,14,10,6,
2,10,2,4,2,2,22,14,4,4,14,2,
12,8,8,6,2,4,8,2,2,14,14,12,
16,10,14,18,4,28,36,8,8,4,10,
18,16,2,30,72,6,44,16,30,10,
22,26,4,16,26,22,16,4,8,10,
6,4,20,4,2,20,6,20,4,6,4,4,
6,8,8,6,8,6,2,2,18,4,34,16,22,
24,34,22,96,20,66,4,8,4,6,8,8,
8,30,16,8,22,6,22,6,16,18,18,36,
26,22,2,8,30,16,12,6,20,26,8,22,
4,12,8,22,14,4,34,20,66,20,6,18,
58,68,24,54,40,34,40,20,28,14,20,
38,20,14,28,32,66,34,34,30,106,32,
36,2,30,40,88,40,18,24,8,16,8,6,
28,8,2,2,6,26,14,34,32,22,22,34,
28,86,22,28,52,2,2,10,16,12,4,
20,28,14,8,16,6,8,4,14};
void main(void)
{
mLatterIndex=1;
//set_lcd_xy(100,100);
sl=pgm_read_byte(&StrLength[mLatterIndex]);//pgm_read_byte(address short)
//Disp_Int(sl,3);
//set_lcd_xy(200,100);
sll=pgm_read_byte(&StrLength[1]);
// Disp_Int(sl,3);
}
答 6: 谢谢lee_t_1000谢谢lee_t_1000大哥,你解决了我n天未解决的问题,谢谢!!! 答 7: 我用的是PRG_RDB这个宏,问题解决了但又有一个新的问题:
#include <AVR/pgmspace.h>
const char foo[] PROGMEM = "Foo";
const char bar[] PROGMEM = "Bar";
PGM_P array[2] PROGMEM = {
foo,
bar
};
int main (void)
{
char buf[32];
strcpy_P (buf, array[1]);
return 0;
}
这是LIB文档上的例子,变量为PGM_P指针形的,这时如果将其中的array[1]改为
i=1;
array[i];
同样读取的数据不对,这个如何解决.请教高手. 答 8: 请问请问const char StrLength[] PROGMEM={4,26,18,6,18,34,16,30,24,36,、、、、}
这段数组是否是存在flash还是rom里还是每次都有程序调到ram里啊? 答 9: 就是在Flash里,是一组常数,死的
共2条
1/1 1 跳转至页
回复
有奖活动 | |
---|---|
【有奖活动】分享技术经验,兑换京东卡 | |
话不多说,快进群! | |
请大声喊出:我要开发板! | |
【有奖活动】EEPW网站征稿正在进行时,欢迎踊跃投稿啦 | |
奖!发布技术笔记,技术评测贴换取您心仪的礼品 | |
打赏了!打赏了!打赏了! |
打赏帖 | |
---|---|
与电子爱好者谈读图四被打赏50分 | |
与电子爱好者谈读图二被打赏50分 | |
【FRDM-MCXN947评测】Core1适配运行FreeRtos被打赏50分 | |
【FRDM-MCXN947评测】双核调试被打赏50分 | |
【CPKCORRA8D1B评测】---移植CoreMark被打赏50分 | |
【CPKCORRA8D1B评测】---打开硬件定时器被打赏50分 | |
【FRDM-MCXA156评测】4、CAN loopback模式测试被打赏50分 | |
【CPKcorRA8D1评测】--搭建初始环境被打赏50分 | |
【FRDM-MCXA156评测】3、使用FlexIO模拟UART被打赏50分 | |
【FRDM-MCXA156评测】2、rt-thread MCXA156 BSP制作被打赏50分 |