How to write to a fixed flash address before starting the code, using attiny416?

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

Hi all,

 

My question is how to write the address in a fixed flash, today in PIC12 use xc8 macro, to write in a specific address. But I will migrate my project to attiny416 and I do not know how to declare a constant in a final flash address.

In my project with PIC12, i use an XC8 macro to declare my variable in flash, like this:

 

const char flash_7F8h[4] @ 0x7F8 = {0x01, 0x23, 0x45, 0x67};

 

 

This constant is written at the end of the flash at the address indicated in the declaration. I can still check this constant in my .hex file.

 

:080FF000013423344534673459

 

I would like to do this on attiny416 using atmel studio. Can anybody help me?

 

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

The real question is why the constant needs to be at a specific address in flash, just declare it const and let the compiler decide where it wants to store it, and reference it by name.

 

Jim

 

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

The only way an AVR can write to it's own flash is using the SPM (Self Program Memory) opcode that is usually used to implement bootloaders. Be warned that to write you will need to erase whole flash pages first and erases have a limited life of 10,000 cycles on each page.

 

But most people would use EEPROM for this - why aren't you planning to use that?