当前位置:网站首页>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);边栏推荐
- Matlab学习9-图像处理之非线性锐化滤波
- M1 芯片指南:M1、M1 Pro、M1 Max 和 M1 Ultra
- Asynchronous notification mechanism of character device driver
- Idea pulls items from remote warehouse
- Cron expressions in scheduled tasks
- EN 45545 R24氧指数测试方法解析
- Zipkin入门
- @Usage details of postconstruct, initializingbean and initmethod
- Polymorphic interview questions
- Implementation of CRF for named entity recognition
猜你喜欢

Not eligible for getting processed by all beanpostprocessors

Multiple limit of the same field of SQL

Hibernate L2 cache

Zipkin入门

Web design and website planning assignment 13 making video playlists

结果和目标出入太大?不妨借助目标管理精准直达目标!

(一)aac开篇-核心组件原理之Lifecycle、LiveData、ViewModel与源码分析技巧(转载)

torch. meshgrid

Idea annotation settings

What does it mean to buy a single-mode, dual-mode and Rechargeable Wireless Mouse
随机推荐
复制的代码格式混乱怎么办?
不想项目失控?你需要用对项目管理工具
剑指 Offer 40. 最小的k个数
M1 芯片指南:M1、M1 Pro、M1 Max 和 M1 Ultra
EN45545-2 R26垂直燃烧测试介绍
Can not connect to local MySQL server through socket ‘/tmp/mysql. sock (2)‘
盘它!用「飞项」轻松管理各类型项目
Mongodb--- automatically delete expired data using TTL index
二、渲染 Camera 的数据
剑指 Offer 10- II. 青蛙跳台阶问题
你所不知道的console
2022 Niuke winter vacation 3
ICML2022有意思的文章
Anaconda+tensorflow most effective summary version (blood and tears summary of 6 reloads)
MySQL & Oracle database capacity query
for in / for of / forEach 循环
知识图谱入门之---yedda标注
Sword finger offer 10- ii Frog jumping on steps
Idea annotation settings
XXL task executor calls local project