【iCore4 双核心板_ARM】例程三十七:SDRAM实验——读写SDRAM

实验现象:

上电即开始读写SDRAM测试,测试过程中,蓝色LED点亮,如果出现错误,红色LED闪烁,测试成功,绿色LED点亮。

核心代码:

int main(void)
{ /* USER CODE BEGIN 1 */
int i,j;
/* USER CODE END 1 */ /* MCU Configuration----------------------------------------------------------*/ /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init(); /* USER CODE BEGIN Init */ /* USER CODE END Init */ /* Configure the system clock */
SystemClock_Config(); /* USER CODE BEGIN SysInit */ /* USER CODE END SysInit */ /* Initialize all configured peripherals */
MX_GPIO_Init(); /* USER CODE BEGIN 2 */
//SDRAM³õʼ»¯
BSP_SDRAM_Init();
LED_BLUE_ON;
//ÏòSDRAMÖÐдÈë0x5555²¢¶ÁȡУÑé
for(i = ;i < SDRAM_SIZE;i++){
write_sdram(i,0x5555);
}
for(i = ;i < SDRAM_SIZE;i++){
if(0x5555 != read_sdram(i)){
while(){
LED_RED_ON;
HAL_Delay();
LED_RED_OFF;
HAL_Delay();
}
}
} //ÏòSDRAMÖÐдÈë0xAAAA²¢¶ÁȡУÑé
for(i = ;i < SDRAM_SIZE;i++){
write_sdram(i,0xAAAA);
}
for(i = ;i < SDRAM_SIZE;i++){
if(0xAAAA != read_sdram(i)){
while(){
LED_RED_ON;
HAL_Delay();
LED_RED_OFF;
HAL_Delay();
}
}
}
//ÏòSDRAMÖÐдÈë0x0000~0xFFFF²¢¶ÁȡУÑé
for(j = ; j < ; j++){
for(i = ;i < ;i++){
write_sdram(( * j + i),i);
}
}
for(j = ; j < ; j ++){
for(i = ;i < ;i++){
if(i != read_sdram(( * j + i))){
while(){
LED_RED_ON;
HAL_Delay();
LED_RED_OFF;
HAL_Delay();
}
}
}
}
//²âÊԳɹ¦
LED_BLUE_OFF;
LED_GREEN_ON;
/* USER CODE END 2 */ /* Infinite loop */
/* USER CODE BEGIN WHILE */
while ()
{
/* USER CODE END WHILE */ /* USER CODE BEGIN 3 */ }
/* USER CODE END 3 */ }

源代码下载链接:

链接:http://pan.baidu.com/s/1i5kqcst 密码:d03o

iCore4链接:

【iCore4 双核心板_ARM】例程三十七:SDRAM实验——读写SDRAM

上一篇:OpenStack 企业私有云的若干需求(7):电信行业解决方案 NFV


下一篇:洛谷 [P2661] 信息传递