ICC V8 Compiler question

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

I have a bunch of text strings that I can't waste RAM with so I assigned them in __flash.

 

MEGA8515

 

 __flash char func_name[][21]=
        {
        // MUST be 20 CHARACTERS! use spaces to fill out
        "INPUT#1 unassigned  ",  // 0
        "INPUT#2 unassigned  ",  // 1
        "INPUT#3 unassigned  ",  // 2
        "INPUT#4 unassigned  ",  // 3
        "INPUT#5 USB Audio   ",  // 4
        // DO NOT FILL OUT TO 20 CHARS
        "Processor Loop:",       // 5
        "Sub Woof= DIRECT",      // 6
        "Sub Woof= L+R",         // 7
        "Sub Woof= L+R+LFE",     // 8
        "Surr= Direct",          // 9
        "Surr= Side to Rear",    // 10
        "Surr= Side + Rear",     // 11
        "Surr= Side+Rear -6db",  // 12
        "HEIGHT= Main L-R",      // 13
        "HEIGHT= Rear L-R",      // 14
        "HEIGHT= Side L-R",      // 15
        "dest: 12345678 X"       // 16
        };
 

 

Now do these strings write from ROM to flash each time the program is run or do they go into flash once and just stay there.

 

My concern is wearing out the flash RAM, typically 10,000 writes max. The target device is powered up and restarted daily.

 

THX

 

P.S. It's for a custom DSP audio surround processor if you must know.

Last Edited: Tue. Jan 11, 2022 - 06:34 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The __flash *is* the "ROM".

Moderation in all things. -- ancient proverb

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

Welcome to AVRFreaks

 

DelleA wrote:
do these strings write from ROM to flash

The  MEGA8515 doesn't have ROM

 

DelleA wrote:
My concern is wearing out the flash RAM

Not sure what you mean by that - Flash & RAM are 2 separate things:

  • Flash is the non-volatile storage - only written during programming
  • RAM is SRAM - volatile read/write memory

 

custom DSP audio surround processor

on an AVR! surprise

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The flash is only written after you have built your code and come to program the code into the AVR. Just because you made something "__flash" does not mean it's magically rewritten each time you apply power. Only your ISP programmer can actually write the flash and work through those 10,000 cycles (which in reality is probably considerably more than 10,000 in fact) 

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

 

Don't forget to check the strings in flash box!

 

This tells the compiler to place strings in flash, and to use the appropriate method to access same in the program when needed. 

This avoids the unnecessary copy of strings from flash to ram during the c runtime code that runs before main() starts....

 

Jim

Here I thought I was the only ICC user here!

 

 

 

FF = PI > S.E.T

 

Last Edited: Tue. Jan 11, 2022 - 07:24 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Here's an example of using strings that have been stored in flash memory:

 

const char DOW0[] PROGMEM = "Sunday";
const char DOW1[] PROGMEM = "Monday";
const char DOW2[] PROGMEM = "Tuesday";
const char DOW3[] PROGMEM = "Wednesday";
const char DOW4[] PROGMEM = "Thursday";
const char DOW5[] PROGMEM = "Friday";
const char DOW6[] PROGMEM = "Saturday";
const char DOW7[] PROGMEM = "Sunday";

 

const char * const  DOWArray[ 8 ] PROGMEM =
   { DOW0, DOW1, DOW2, DOW3, DOW4, DOW5, DOW6, DOW7 };

 

uint8_t   * myPtrToFlashString, myBuffer[22], dayOfTheWeek =2;

 

 

        myPtrToFlashString = (char *) pgm_read_word (& DOWArray[ dayOfTheWeek] );
        strcpy_P ((char *) myBuffer, myPtrToFlashString);
       print(myBuffer);  // prints "Tuesday"

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


ICC does not use/understand PROGMEM that is a gcc thing!

 

From the ICC manual under Strings

 

FF = PI > S.E.T

 

Last Edited: Tue. Jan 11, 2022 - 07:52 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

OK, got it. I thought perhaps there was different Flash areas for the code and user.

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

DelleA wrote:
I thought perhaps there was different Flash areas for the code and user.

code -> flash

user -> eeprom

 

assuming user needs non-volatile memory storage, as flash is difficult to write to from user programs, as it can only be written from "bootloader" memory space and then only in pages at a time.....

 

 

FF = PI > S.E.T