Friday, February 23rd 2018, 7:47am UTC+1

You are not logged in.

  • Login
  • Register



Date of registration: Jan 20th 2009

Posts: 1


Tuesday, January 20th 2009, 8:36pm

embOS OS_malloc and memory usage... where's it come from?

I have a question on "third party" packages using malloc(). I am using an external RAM chip on an Infineon CPU, using embOS and emWin on a new product. I believe that emWin needs to allocate memory within a call. For instance when creating a Sprite, some memory needs to be available. The question is how do I tell emWin or embOS which and where the RAM is located in the address space?

Date of registration: Dec 20th 2007

Posts: 26


Wednesday, January 28th 2009, 9:47am

emWin does not allocate dynamic memory from the heap.
A heap is not required and malloc() is not used.
emWin comes with it's own memory management module.
The "dynamic" memory used by emWin can be configured using the GUI_ALLOC_* functions.
In our samples, we use the GUI_X_Init() function to allocate the memory:
#define GUI_NUMBYTES 0x100000
#define GUI_BLOCKSIZE 128

void GUI_X_Config(void) {
static U32 aMemory[GUI_NUMBYTES >> 2];
GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
The GUI_ALLOC_AssignMemory() function takes a pointer to the base address of the memory pool.
There is no need to use a variable.
Using a variable has the advantage, that the linker controls the size and address of the memory and it can not be used twice.