Memory
Detailed Description
The MCU ATmega128 has three different types of memory:
- PROGMEM - program memory, flash technology, size 128KB
- RAM - 4KB
- EEPROM - 4KB
TODO external 256KB SRAM
Some of the functions can access any of the memories.
Memory model
For developer following functions simplify the memory access:
For wb() and ww() only the RAM or EEPROM makes sence.
For RAM allocation you can use the standard malloc(), free() calls and
To access EEPROM you must use emalloc(), efree() calls.
To insert some data into PROGMEM in compilation time you can use the attribute PROGMEM. Example: u8 PROGMEM data[]={0,1,2,3};
includes {0,1,2,3} into PROGMEM.
To access such data you must use rb() or rw() calls.
u8 PROGMEM data[]={0,1,2,3};
u8 x;
u8 i;
for(i=0;i<sizeof(data);i++) x=rb(data+i);
- Attention:
- Because or very little RAM we suggest to put everything possible into PROGMEM, esp. strings.
There is a very little stack so use malloc()/free() rather than local arrays.
- For details on PROGMEM please refer to AVR LIBC documentation.
Typedefs
- typedef unsigned char u8
- typedef unsigned short u16
- typedef unsigned long u32
- typedef char b8
- typedef short b16
- typedef long b32
Functions
Typedef Documentation
| typedef unsigned short u16
|
|
| typedef unsigned long u32
|
|
Function Documentation
|
|
Return pointer on application persistent data. |
|
|
Pointer on buffer 1072 bytes long. Can be used only during one action. Content can be rewritten between actions. |
| void efree |
( |
void * |
ptr |
) |
|
|
|
|
Free emalloc'ed chunk. - Parameters:
-
|
| void* emalloc |
( |
u16 |
size |
) |
|
|
|
|
Same as malloc but in EEPROM. - Parameters:
-
|
| u8 ext_sram_rb |
( |
u32 |
addr |
) |
|
|
|
|
Read byte from extern 256KB SRAM. - Parameters:
-
|
| void ext_sram_wb |
( |
u32 |
addr, |
|
|
u8 |
value |
|
) |
|
|
|
|
Write byte to extern 256KB SRAM. - Parameters:
-
|
| u8 rb |
( |
const void * |
addr |
) |
|
|
|
|
Read byte from memory. - Parameters:
-
| addr | EEPROM, PROGMEM, RAM memory address. |
|
| void reg_app_data |
( |
void * |
data |
) |
|
|
|
|
Store (in EEPROM) pointer on application persistent data. - Parameters:
-
|
| u16 rw |
( |
const void * |
addr |
) |
|
|
|
|
Read word from memory. - Parameters:
-
| addr | EEPROM, PROGMEM, RAM memory address. |
|
| void wb |
( |
void * |
addr, |
|
|
u8 |
val |
|
) |
|
|
|
|
Write byte to memory. - Parameters:
-
| addr | EEPROM, RAM memory address. |
| val | value. |
|
| void ww |
( |
void * |
addr, |
|
|
u16 |
val |
|
) |
|
|
|
|
Write word to memory. - Parameters:
-
| addr | EEPROM, RAM memory address. |
| val | value. |
|
| Copyright © 2004 BLADOX
| Turbo Programmer version 2.0
|