当前位置:网站首页>GCC AVR (ATMEL studio+ AVR studio) how to define the structure array in the program memory (flash) space and read it
GCC AVR (ATMEL studio+ AVR studio) how to define the structure array in the program memory (flash) space and read it
2022-06-11 08:45:00 【ba_ wang_ mao】
One 、 Defining structure
To add #include <avr/io.h>.
#include <avr/io.h>Then define the following structure .
typedef struct tagFORMAT_SET_STRUCT
{
uint8_t Decimal;
int16_t Min;
int16_t Max;
int16_t Default;
} FORMAT_SET_STRUCT,*FORMAT_SET_STRUCT_PTR;Two 、 Add header file <avr/pgmspace.h>
Only add header files <avr/pgmspace.h> To program memory (flash) Definition and read operation of .
#include <avr/pgmspace.h>3、 ... and 、 Use keywords PROGMEM const Define an array of structures
PROGMEM const FORMAT_SET_STRUCT SET_DEFAULT_BUFFER[30] = {
{0x00 , 0 , 9999 , 0},
{0x01 , 0 , 1000 , 0},
{0x03 , 0 , 29999 , 2430},
{0x03 , 0 , 29999 , 280},
{0x03 , 0 , 29999 , 0},
{0x01 , 0 , 8 , 6},
{0x01 , 0 , 100 , 0},
{0x00 , 0 , 3 , 0},
{0x00 , 1 , 2 , 2},
{0x00 , 0 , 1 , 0},
{0x01 , 0 , 200 , 100},
{0x00 , 0 , 1 , 0},
{0x00 , -40 , 40 , 4},
{0x00 , 1 , 200 , 1},
{0x00 , 0 , 8 , 6},
{0x00 , 0 , 2 , 0},
{0x00 , 0 , 1 , 0},
{0x00 , 0 , 32767 , 1206},
{0x00 , 0 , 32767 , 6341},
{0x00 , 0 , 32767 , 350},
{0x00 , 0 , 32767 , 2410},
{0x00 , 0 , 32767 , 4218},
{0x00 , 0 , 32767 , 21006},
{0x00 , 0 , 32767 , 4222},
{0x00 , 0 , 32767 , 21035},
{0x00 , 0 , 4095 , 812},
{0x00 , 0 , 4095 , 3862},
{0x00 , 0 , 4095 , 694},
{0x00 , 0 , 4095 , 3488},
{0x00 , 0 , 1 , 0},
};Four 、 Structure array read operation
1、 Read the 16 Digit value , Use pgm_read_word(&) Library function
for example :
int16_t m;
m = pgm_read_word(&SET_DEFAULT_BUFFER[0].Default);2、 Read the 8 Digit value , Use pgm_read_byte(&) Library function
for example :
uint8_t n;
n = pgm_read_byte(&SET_DEFAULT_BUFFER[1].Decimal);边栏推荐
- Bat batch processing separate environment packaging
- M1 芯片指南:M1、M1 Pro、M1 Max 和 M1 Ultra
- CMVSS TSD No. 302与49 CFR 571.302测试方法是否一样
- 哪些Apple设备支持这次系统更新?来看你的旧Apple设备支持最新系统吗
- (一)aac开篇-核心组件原理之Lifecycle、LiveData、ViewModel与源码分析技巧(转载)
- Codeworks round 723 (Div. 2)
- Cron expressions in scheduled tasks
- Sword finger offer 51 Reverse pair in array
- Swagger study notes
- 字符设备驱动程序之异步通知机制
猜你喜欢
![[software tool] the hacker matrix special effect software CMatrix](/img/d3/bbaa3dfd244a37f0f8c6227db37257.jpg)
[software tool] the hacker matrix special effect software CMatrix

Oracle learning (I)

qiao-lerna:lerna辅助工具

@Usage details of postconstruct, initializingbean and initmethod

字符设备驱动程序之异步通知机制

leetcode - 460. LFU cache

Codetop - sort odd ascending even descending linked list

Sword finger offer 21 Adjust array order so that odd numbers precede even numbers

Hibernate L2 cache

结果和目标出入太大?不妨借助目标管理精准直达目标!
随机推荐
Matlab学习8-图像处理之线性与非线性锐化滤波、非线性平滑滤波
Asynchronous notification mechanism of character device driver
Pycharm启动卡死,loading project
[software tool] the hacker matrix special effect software CMatrix
ActiveMQ简单教程,适合初学者,学习笔记yyds
进程间的通信
Qiao NPMS: get the download volume of NPM packages
Web design and website planning assignment 13 making video playlists
【CVPR2022】QueryDet论文精读
GO语言:字符串的连接、数字转化字符串
What is concurrent search set? Are you still worried about it? In fact, it is a problem of connected graph, which is not so difficult to understand
Codeworks round 680 div2
Using flying items to manage by objectives, not being a "headless fly" in the workplace
Sword finger offer 40 Minimum number of K
bat 批处理单独环境打包
用飞项进行目标管理,不做职场上的“无头苍蝇”
【clickhouse专栏】新建库角色用户初始化
leetcode - 739. Daily temperature
Introduction to database system experiment report answer Experiment 5: database single table query
Polymorphic interview questions