Nuvoton
/
NuMaker-mbed-noXRAM-example
NuMaker without external SRAM configuration
Diff: main.cpp
- Revision:
- 1:a3b9047e5ae0
- Parent:
- 0:763694026416
--- a/main.cpp Wed Mar 01 02:56:10 2017 +0000 +++ b/main.cpp Wed Mar 01 13:03:04 2017 +0800 @@ -1,10 +1,30 @@ #include "mbed.h" // main() runs in its own thread in the OS - int main() { - // TO BE EXTENDED + while (true) { + void *heap = new uint8_t[32]; + + uint32_t heap_ = ((uint32_t) heap) & 0xF0000000; + switch (heap_) { + case 0x20000000: + printf("Heap allocated at 0x%08x (IRAM)\r\n", heap); + break; + + case 0x60000000: + printf("Heap allocated at 0x%08x (XRAM)\r\n", heap); + break; + + default: + printf("Heap allocated at 0x%08x (ILLEGAL)\r\n", heap); + } + + delete [] heap; + heap = NULL; + + wait(2.0); + } + return 0; } -