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

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "sdram.h"
00003 #include "USBSerial.h"
00004 
00005 DigitalOut led1(LED1);
00006 USBSerial cdc;
00007 Serial pc(USBTX,USBRX);
00008 
00009 #define SIZE (1024*1024)
00010 
00011 int alloccount = 0;
00012 unsigned char *ptr[100] ;
00013 
00014 int main() {
00015     sdram_init();
00016     while(1) {
00017         ptr[alloccount] = (unsigned char *)malloc(SIZE) ;
00018         cdc.printf ("Allocated Address = %08X\r\n",ptr[alloccount]);
00019         pc.printf ("Allocated Address = %08X\r\n",ptr[alloccount]);
00020         if (ptr[alloccount] == NULL) {
00021             cdc.printf("MAX ALLOC MEMORY %d MB\r\n",alloccount);
00022             pc.printf("MAX ALLOC MEMORY %d MB\r\n",alloccount);
00023             for (int i=0;i<alloccount;i++) {
00024                 free(ptr[i]);
00025             }
00026             alloccount = 0;
00027         } else {
00028             alloccount++ ;
00029         }
00030         led1 = 1;
00031         wait(0.1);
00032         led1 = 0;
00033         wait(0.1);
00034     }
00035 }