板子是GD32450i-EVAL,用官方例程14_EXMC_SDRAM,增加一个打印
/* compare two buffers */
for(i = 0;i < BUFFER_SIZE;i++){
if (rxbuffer[i] != txbuffer[i]){
printf("\r\nfail[%d]:%d != %d", i, rxbuffer[i], txbuffer[i]);
writereadstatus ++;
break;
}
}
打印结果:
fail[0]:96 != 0
就是说SDRAM的第一个字节写入错误。
我自己写的代码:
uint8_t *pbAddr = (uint8_t *)EXMC_SDRAM_ADDR0;
*pbAddr = 0x00;
*(pbAddr + 1) = 0xaa;
*(pbAddr + 1024) = 0x00;
*(pbAddr + 1024 + 1) = 0xaa;
Printf("[%x] = 0x%x\n", (uint32_t)pbAddr, *pbAddr);
Printf("[%x] = 0x%x\n", (uint32_t)(pbAddr + 1), *(pbAddr + 1));
Printf("[%x] = 0x%x\n", (uint32_t)(pbAddr + 1024), *(pbAddr + 1024));
Printf("[%x] = 0x%x\n", (uint32_t)(pbAddr + 1024 + 1), *(pbAddr + 1024 + 1));
打印结果:
[c0000000] = 0x0
[c0000001] = 0xaa
[c0000400] = 0x40
[c0000401] = 0xaa
有人知道查问题的方向吗?不稳定导致的?但是每次的错误都是一样的。
SDRAM初始化寄存器值和发送的Command值
REG_EXMC_SDCTL:39d9
REG_EXMC_SDTCFG:1115461
Command:11
Command:12
Command:f3
Command:46014 |