sdram and cdc,hdk serial test program for EA4088 mbed. HDK Serial stopped after a while, but CDC Serial and LED HeartBeat is alive.
Dependencies: EALib USBDevice mbed
main.cpp@0:0e8a8d6e4cfd, 2013-10-06 (annotated)
- Committer:
- mio
- Date:
- Sun Oct 06 04:24:24 2013 +0000
- Revision:
- 0:0e8a8d6e4cfd
SDRAM malloc test; HDK Serial (pc) is stopped after a while,; But LED and CDC Serial is alive.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mio | 0:0e8a8d6e4cfd | 1 | #include "mbed.h" |
mio | 0:0e8a8d6e4cfd | 2 | #include "sdram.h" |
mio | 0:0e8a8d6e4cfd | 3 | #include "USBSerial.h" |
mio | 0:0e8a8d6e4cfd | 4 | |
mio | 0:0e8a8d6e4cfd | 5 | DigitalOut led1(LED1); |
mio | 0:0e8a8d6e4cfd | 6 | USBSerial cdc; |
mio | 0:0e8a8d6e4cfd | 7 | Serial pc(USBTX,USBRX); |
mio | 0:0e8a8d6e4cfd | 8 | |
mio | 0:0e8a8d6e4cfd | 9 | #define SIZE (1024*1024) |
mio | 0:0e8a8d6e4cfd | 10 | |
mio | 0:0e8a8d6e4cfd | 11 | int alloccount = 0; |
mio | 0:0e8a8d6e4cfd | 12 | unsigned char *ptr[100] ; |
mio | 0:0e8a8d6e4cfd | 13 | |
mio | 0:0e8a8d6e4cfd | 14 | int main() { |
mio | 0:0e8a8d6e4cfd | 15 | sdram_init(); |
mio | 0:0e8a8d6e4cfd | 16 | while(1) { |
mio | 0:0e8a8d6e4cfd | 17 | ptr[alloccount] = (unsigned char *)malloc(SIZE) ; |
mio | 0:0e8a8d6e4cfd | 18 | cdc.printf ("Allocated Address = %08X\r\n",ptr[alloccount]); |
mio | 0:0e8a8d6e4cfd | 19 | pc.printf ("Allocated Address = %08X\r\n",ptr[alloccount]); |
mio | 0:0e8a8d6e4cfd | 20 | if (ptr[alloccount] == NULL) { |
mio | 0:0e8a8d6e4cfd | 21 | cdc.printf("MAX ALLOC MEMORY %d MB\r\n",alloccount); |
mio | 0:0e8a8d6e4cfd | 22 | pc.printf("MAX ALLOC MEMORY %d MB\r\n",alloccount); |
mio | 0:0e8a8d6e4cfd | 23 | for (int i=0;i<alloccount;i++) { |
mio | 0:0e8a8d6e4cfd | 24 | free(ptr[i]); |
mio | 0:0e8a8d6e4cfd | 25 | } |
mio | 0:0e8a8d6e4cfd | 26 | alloccount = 0; |
mio | 0:0e8a8d6e4cfd | 27 | } else { |
mio | 0:0e8a8d6e4cfd | 28 | alloccount++ ; |
mio | 0:0e8a8d6e4cfd | 29 | } |
mio | 0:0e8a8d6e4cfd | 30 | led1 = 1; |
mio | 0:0e8a8d6e4cfd | 31 | wait(0.1); |
mio | 0:0e8a8d6e4cfd | 32 | led1 = 0; |
mio | 0:0e8a8d6e4cfd | 33 | wait(0.1); |
mio | 0:0e8a8d6e4cfd | 34 | } |
mio | 0:0e8a8d6e4cfd | 35 | } |