How can I populate a lookup table in DSEG?

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

Disregard.  I was trying to initialise DSEG with a lookup table, but I have just realised that DSEG is SRAM, so any initialised value disappears at power-down.

Duh!  The realisation took a long time in the coming.

Last Edited: Sat. Apr 29, 2017 - 06:47 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it's data that can be changed then you need an LPM/ST loop that reads the defaults from flash to RAM (DSEG) then you. This is almost exactly what the CRT loop that sets up .data in a C program is doing. 

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

Yes.  Initially, I thought it would be sensible to put data (my lookup table) in the Data segment, and I spent almost all day trying to figure out how to do it.  Finally, I came to the forum to ask, and immediately after posting, I realised that I was trying to store permanent data in volatile memory - so I edited the question to tell any responder to ignore the it.

A whole day barking up the wrong tree!  We live and learn.  That's another one I'll know in the future.

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

As I say almost every AVR C program in existence does this so not such an unusual requirement. 

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

I wouldn't know.  I have never had any interest in AVR C programs (I'm using ASM) and as this is the first program of any sort that I have written on an AVR, I have no knowledge of "every AVR" program.