Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 184987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:23:25+00:00 2026-05-11T15:23:25+00:00

The problem I can’t get the data from the Flash memory when using the

  • 0

The problem

I can’t get the data from the Flash memory when using the function that return the address of the pattern desired in the Flash (simplified in the example below with only 1 constant : PATTERN_P).

Some code before explication

The type patternp is defined as

typedef prog_uchar patternp[NUM_ROWS];  

The global PATTERN_P variable is an array of type patternp, defined as

const patternp PATTERN_P PROGMEM = {    0b11110000 ,    0b10010000 ,    0b10010000 ,    0b10010000 ,    0b11110000 ,    0b10000000 ,    0b10000000 ,    0b10000000  }; 

getpattern():

const patternp * getPattern() {       //...        return &PATTERN_P; } 

main():

const patternp *bufferPattern = getPattern();  uint8_t rowPatternData[NUMBER_ROW_PER_MATRIX]; const patternp *bufferPattern = getPattern(s[iLetter]);   for(int iRow = 0; iRow<NUMBER_ROW_PER_MATRIX; iRow++) {       rowPatternData[iRow]=pgm_read_byte( &PATTERN_P[iRow] );   // <--- WORK!     rowPatternData[iRow]=pgm_read_byte( bufferPattern[iRow] ); // Not Working!   } 

Explications

As you can see, the code get the pattern (in this example, it will return PATTERN_P every time… than I use pgm_read_byte to get the data from the Flash memory. This use the AVR pgmspace (link below). It takes an address and return the data. The code above work when I use the direct access of a template : &PATTERN_P[iRow], but won’t work when I use bufferPattern[iRow] or &bufferPattern[iRow]. Any idea?

Reference : pgm_read_byte is defined in pgmspace

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T15:23:25+00:00Added an answer on May 11, 2026 at 3:23 pm

    bufferPattern is a pointer to an array. When you write bufferPattern[iRow], this does NOT evaluate to a pointer to entry iRow of patternp; the [] operation is acting on the pointer, not the array it points to. What you appear to want to write is &((*bufferPattern)[iRow]).

    That will fix the immediate problem. However, the code is a bit confusing. It may be that your code would be simplified by passing the array directly (C does not pass arrays by value; so it won’t copy the array – you don’t need to make a pointer to the array to avoid this).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 105k
  • Answers 105k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer dev_appserver.py --clear_datastore=yes myapp See here for more info. Shorthand version:… May 11, 2026 at 8:39 pm
  • Editorial Team
    Editorial Team added an answer This works in VB.NET 2005, not sure about 1.1. I… May 11, 2026 at 8:39 pm
  • Editorial Team
    Editorial Team added an answer Since the standard function .slideDown and .slideUp will do the… May 11, 2026 at 8:39 pm

Related Questions

I am currently running into a problem where an element is coming back from
Here's the problem I'm having, I've got a set of logs that can grow
I'm new to WPF and data binding so hopefully I can explain the problem
I have a bit of code, which I can't figure out properly. The problem
Let me describe the problem and the solution i currently have and maybe you

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.