27,511
社区成员




int i,j;
class Test
{
public:
int X,Y;
Test(int x,int y)
{
X = x;
Y = y;
}
};
int main(void)
{
SDRAM_Init();
for(i = 0;i<100000;i++)
{
Test *ptest = new Test(1,1);//测试是否能在SDRAM中分配内存并且使用
}
while(1)
{
}
#include "stm32f4xx_conf.h"
#include "stm32f429i_discovery_sdram.h"
#include <rt_heap.h> //_init_alloc
#define IS42S16400J_SIZE 0x400000
#define HEAP_BASE SDRAM_BANK_ADDR
#define HEAP_TOP (SDRAM_BANK_ADDR+IS42S16400J_SIZE)
int i,j;
class Test
{
public:
int X,Y;
char cs[10000];
Test(int x,int y)
{
X = x;
Y = y;
}
};
Test *ptest = 0;
int main(void)
{
// RCC_ClocksTypeDef clock;
// RCC_GetClocksFreq(&clock);
SDRAM_Init();
_init_alloc(HEAP_BASE, HEAP_TOP); // 设置堆空间
int *p = new int[16000];
for(i = 0;i<10000;i++)
{
ptest = new Test(1,1);//测试是否能在SDRAM中分配内存并且使用
j = ptest->Y;
//delete ptest;
}
while(1)
{
j++;
}
}
当然程序会飞掉,主要是看ptest 的地址有没有达到或接近0xD0400000,如果接近了那么SDRAM作为堆内存就实验成功!
给学习的同学一点参考。