测试代码如下
while (1) {
//#define SDRAM_TEST_BYTE
//#define SDRAM_TEST_SHORT
#define SDRAM_TEST_LONG
#ifdef SDRAM_TEST_BYTE
for (uint32_t i = 0; i < SDRAM_DEVICE_SIZE; i += 0x01) {
*(volatile uint8_t *)(SDRAM_DEVICE_ADDR + i) = 0xA5;
tmp = *(volatile uint8_t *)(SDRAM_DEVICE_ADDR + i);
if (tmp == 0xA5) {
#endif
#ifdef SDRAM_TEST_SHORT
for (uint32_t i = 0; i < SDRAM_DEVICE_SIZE; i += 0x02) {
*(volatile uint16_t *)(SDRAM_DEVICE_ADDR + i) = 0xA512;
tmp = *(volatile uint16_t *)(SDRAM_DEVICE_ADDR + i);
if (tmp == 0xA512) {
#endif
#ifdef SDRAM_TEST_LONG
for (uint32_t i = 0; i < SDRAM_DEVICE_SIZE; i += 0x04) {
*(volatile uint32_t *)(SDRAM_DEVICE_ADDR + i) = 0x12345678;
tmp = *(volatile uint32_t *)(SDRAM_DEVICE_ADDR + i);
if (tmp == 0x12345678) {
#endif
HAL_Delay(100);
BSP_LED_Toggle(LED1);
} else {
HAL_Delay(100);
BSP_LED_Toggle(LED2);
}
}
}
焊了两片核心板,单片机是 STM32F429IGT6,SDRAM是 W9812G6GH-6,其中一块完全测试通过的,另外一块按8位或者16位测试也是通过的,但是按32位写读测试就有误,写进去是 0x12345678,读出来变成 0x12345634了,不知道是什么问题,有人遇到过吗?
其中一块测试无问题,说明软件时序应该是没问题;如果是硬件问题,那按8位16位测试又是正常的,真是邪了!!!
|