Search code examples
cassemblyavr

Storing table at different memory address - C for AVR XMEGA256A3BU


I'm trying to figure out how to store the fahrenheit table to memory address 0x20 instead of the default 0x0000. I have tried several routes, but so far, nothing that works. The code is in C.

#include <avr/io.h> 
#include <avr/eeprom.h> 

int main(void) 
{ 
    uint8_t fahrenheit[20] =
         {32,34,36,37,39,41,43,45,46,48,50,52,54,55,57,59,61,63,64,66}; 

    for(int i = 0; i < 20; i++) 
   {  
       eeprom_write_byte((uint8_t *)i, fahrenheit[i]); 
   }         
}

Solution

  • eeprom_write_byte((uint8_t *)i, fahrenheit[i]); writes a value to address i. Therefore, to write value starting from 0x0020 as you wish, just do this eeprom_write_byte((uint8_t *)i+20, fahrenheit[i]);