Electronic – How to know the size of the code in Atmel Studio

atmel-studioavr-gcc

I'm new with Atmel Studio and I'm playing with ATtiny13. This mcu has 1K Bytes of Flash, 64 Bytes of EEPROM and 64 Bytes of SRAM.

I would like to know how much memory (flash, eeprom and sram) my code takes.

This is a piece of my compilation output.

I think my code takes 882 bytes of Flash and 15 bytes of EEPROM. Is that right?

Thanks in advance.
code

Best Answer

The amount of memory your program uses has already been answered in the comments, but I would like to clarify how these different types of memory are used.

Flash is used to store the machine code that the CPU executes. It is nonvolatile, and is generally not modified at run-time (i.e. the flash is written once during upload, but it is not modified later by the CPU).

SRAM is where variables are stored. It is volatile, so the nothing is written into SRAM while the code is being uploaded. Rather, it is only modified by the CPU while it is running.

EEPROM is nonvolatile, but can also be modified by the CPU while it is running. The only way to access it is with special EEPROM registers such as EEDR, the EEPROM data register, EECR, the EEPROM control register, EEAR, the EEPROM address register, and several others. In order to read a byte of EEPROM for example, you must load the address of the byte you want into EEAR, then read the byte from EEDR. It is thus much slower to access EEPROM than SRAM. There is really no reason to use EEPROM except when you have modifiable data that you want to keep even when the ATtiny is unplugged.

By default, the compiler does not store any data in EEPROM, though it can be configured to do so.