Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 1 month ago.
HOW to use on board DRAM
I use DISCO-F746NG board and I want to extend memory by using on-board DRAM.
There is API of this board "BSP_DISCO_F746NG" and it contains "stm32746g_discovery_sdram.h" and ".c" file. In C file.
I try under code,but I cannot Read and Write DRAM.
#include "mbed.h" #include "stm32746g_discovery_sdram.h" Serial pc(SERIAL_TX, SERIAL_RX);//9600bps void main(){ //initialize and check init status. //I got a "SDRAM init OK" message. if(status == SDRAM_OK) { pc.printf("SDRAM init OK\n"); } else if(status == SDRAM_ERROR) { pc.printf("SDRAM init ERR\n"); } else if (status == 0x5) { pc.printf("SDRAM init never done\n"); } else {} //mem check:To assign data to all memory and check it. uint32_t start_addr= 0xC0000000;//In stm32746g_discovery_sdram.h, it tell me Device address. uint32_t mask = 0x0fffffff; uint32_t data = 0x10000000; uint32_t read_data = 0x10000000; uint32_t point_of_data =0x0000000f; uint32_t i; //mem check write for(i=0; i<point_of_data; i++) { BSP_SDRAM_WriteData_DMA(start_addr+i,&data,0x1); pc.printf("write: addr is %x, data is %x\n",start_addr+i,data); data ++; } //mem check read for(i=0; i<point_of_data; i++) { BSP_SDRAM_ReadData(start_addr+i,&read_data,0x1); pc.printf("addr is %x, data is %x\n",start_addr+i,read_data); if(data&mask == i) { //data masked off upper 4bit is equal data. //data is OK } else { pc.printf("mem check is error\n"); }; }
Do I mistake using SDRAM? Please teach me some hints... thanks.
Referrence (TS_DISCO_F746 lib) https://developer.mbed.org/teams/ST/code/TS_DISCO_F746NG/
(BSP_DISCO_F746NG lib) https://developer.mbed.org/teams/ST/code/BSP_DISCO_F746NG/