need help going from PROGMEM to SDRAM

Go To Last Post
6 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I have a project that defines a static array for an LCD.

const char lcd_data[192] PROGMEM = { ... };

 

I need to change this array so that I can modify it now. So I figured I could simply use a normal char

char lcd_data[192] = {...};

 

but that really messes up the LCD data. I'm guessing it has to do with the way the array is stored but I can't see to get it right.  I'm using an atmeg328.

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I could simply use a normal char

char lcd_data[192] = {...};

That should work.  Did you change all the pgm_read_xxx() calls to simple references?

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah... nuts, bingo.

 

this is my read/send

    for (int d = 0; d < 192; d++)
    {
        sendData( tmp = pgm_read_byte(lcd_data + (d&0xfc) + (3-(d&0x03))) );//LCD Data
        parity ^= tmp;
    }

 

I'll have to stupid this for a bit, but yeah I'll need to get that out.

Last Edited: Sun. Dec 14, 2014 - 01:23 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think you could replace pgm_read_byte with a single star in that case.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

In that is the case. Thx for help.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Just switch to using "const __flash" then you drop all the pgm_*() stuff anyway and the compiler will make the right access whether it's in RAM or flash.