Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

How much data can I save using PROGMEM, on the Arduino platform (Atmega328)?

For example:

prog_char path[] PROGMEM = {'M',103,95,'U',0,0,'M',103,95,'M',103,95,'M',103,95,'M',103,95,'M',
103,95,'M',103,95,'M',103,95,'M',101,94,'M',100,93,'M',99,92,'M',98,91,'M',98,90,'M',97,89,'M',
96,87,'M',95,85,'M',95,85,'M',94,85,'M',94,84,'M',93,82,'M',92,82,'M',92,82,'M',90,79,'M',89,78,
'M',89,78,'M',88,77,'M',88,75,'M',87,75,'M'}

(Numbers go up to 180.)

Where can i find this information?

share|improve this question
1  
The stack is in program memory? –  AngryEE Feb 21 '12 at 17:43
    
@tyblu, AngryEE is right to question, stack is in SRAM, PROGMEM macro places stuff in program memory (flash) –  Jon L Feb 21 '12 at 18:27
    
Perhaps I should familiarize myself with Arduinos before commenting in the future, @JonL ;) ... comment deleted. –  tyblu Feb 21 '12 at 18:36
    
@tyblu, Just an FYI, Not sure if you're into Atmel's offerings, but the PROGMEM macro and types are defined in the avr-gcc library pgmspace.h - very useful if you're trying to squeeze as much as you can out of your AVR :) (so not just an Arduino specific thing) –  Jon L Feb 21 '12 at 19:25

1 Answer 1

To see how much memory is available on your arduino, check the GUI after it uploaded the code: "Binary sketch size x bytes (of y byte maximum)". \$ y-x \$ would be the amount available to place data in.

Or check the tech specs of your Arduino for the value of Flash Memory. All Arduinos with a 328 offer 32kByte of flash, 2k of which is taken by the bootloader, your sketch may take 4k or so, to be on the safe side I would not store more than 20kByte of data.

share|improve this answer
    
ok and so i can compute how many char i can put it with: (y-x)/2 considering a prog_char type 2 bytes long. is it right? –  nkint Feb 21 '12 at 13:17
1  
prog_char is 1 byte long. You can check the size of a type with the sizeof function, see coverclock.blogspot.com/2012/02/arduino-data-types.html –  posipiet Feb 21 '12 at 16:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.