whats the best way to see how much heap i should set for my program? How to detect if there is not enough heap?
Always recommended to keep the HeapSize as 0x400 and heap size as 0x800 to be on safer side.
Can you call the USBDevice->Reset() and then IsOpen?
right now i have the Heap size at 0x800 and the stack size also at 0x800. When i had the heap at 0x400 the BLE stack hang up. I also have quite som printf()'s in my program for debugging, i think thats whats eating up the heap.
Anyways, what i was looking for was a way to see something like "oh, ok so i use now 79 % of my heap, i could turn it down a bit", so i want to have something like a level indicator for the heap. Is that what you want to do with the IsOpen?
Can you clarify the process you suggested, i dont really know what to do exactly.
To be honest, there is no need to "turn down the heap".
You have got 3 ram memory areas: Program static data, stack and heap. Any ram that is not in the range of one of the areas is non-existing for your C-program and as such not (easily) accessible. Static data area and stack are fixed, so best practice would be to use all the rest for the heap. Unfortunately this is not done automatically as in other languages like PASCAL. So (as long as this is not changed) you will have to calculate your heap amount yourself and check the resulting pointer from malloc() to be non-NULL.
Of course you may encapsulate malloc() and free() into your own routines and so keeping track of the amount of heap currently in use.