GCC中把大数组存入flash区的方法大全
AVRGCC中将变量定义在flash空间的方法(大数据存储)
(1)flash常量:
#include //须增加的头文件
const prog_uchar FlashConst = 3; //定义uchar型的常量n定义在flash里(flash常量)
unsigned char RamVar; //定义无符号整型变量(Ram变量)
RamVar = pgm_read_byte(&FlashConst); //读取flash常量到ram变量
(2)flash一维数据:
#include
const prog_uchar s[5] = { 1, 2, 3, 4, 5 };
unsigned char RamVar; //定义无符号整型变量(Ram变量)
RamVar = pgm_read_byte( &s[1] ); //读取s[1]的值到RamVar, or RamVar = pgm_read_byte( s+1 );
(3)flash多维数据:
#include
const prog_uchar s[4][16] = { {14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7 },
{ 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8 },