大家好,
单板回来一周了,现在卡在了DDR初始化这里。还请大家有见过的,帮忙看下。
处理器:dm368,
ddr:美光,具体型号明天补上。
故障描述:在ubl里,完成初始化后,dm368的ddr控制器,只要使能ddr后,DDR_CS始终为低。无论是读、写,还是没有读写下的自刷新。
而如果在ubl的代码中,在不使能ddr,那么DDR_CS就可以为高。
这证明,DDR_CS本身应该是可高可低,没有硬件错误拉死到低电平。
单板环境特性,定义了ARM432_DDR340_OSC24,也就是单板的晶振是24MHZ,ARM时钟432M,DDR时钟340M。
我的UBL设备初始化代码如附件,其中ddr2初始化之后,在DEVICE_DDR2Init()的末尾,也就是
执行DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_ENABLE);使能DDR2时钟后,DDR接口的DDR_CS信号一直保持
低电平,写入数据0x5a5a5a5a后读回的却是规律的乱数据,是每八字节重复,像是ddr处于IDLE状态。不知道这种情形问
题出在哪里?请帮忙看看,谢谢!
摘录DDR2的初始化代码
Uint32 DEVICE_DDR2Init()
{
{
Uint32 tRFC, tRP, tRCD, tWR, tRAS, tRC, tRRD, tWTR;
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_ENABLE);
SYSTEM->VTPIOCR = (SYSTEM->VTPIOCR) & 0xFFFF9F3F;
// Set bit CLRZ (bit 13)
SYSTEM->VTPIOCR = (SYSTEM->VTPIOCR) | 0x00002000;
// Check VTP READY Status
while( !(SYSTEM->VTPIOCR & 0x8000)); // Set bit VTP_IOPWRDWN bit 14 for DDR input buffers)
//SYSTEM->VTPIOCR = SYSTEM->VTPIOCR | 0x00004000; // Set bit LOCK(bit7) and PWRSAVE (bit8)
SYSTEM->VTPIOCR = SYSTEM->VTPIOCR | 0x00000080; // Powerdown VTP as it is locked (bit 6)
// Set bit VTP_IOPWRDWN bit 14 for DDR input buffers)
SYSTEM->VTPIOCR = SYSTEM->VTPIOCR | 0x00004040;
// Wait for calibration to complete UTIL_waitLoop( 150 );
// Set the DDR2 to synreset, then enable it again
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_SYNCRESET);
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_ENABLE);
DDR->DDRPHYCR = 0x000000C5;
SYSTEM->VTPIOCR = (SYSTEM->VTPIOCR) & 0xFFFF9F3F;
// Set bit CLRZ (bit 13)
SYSTEM->VTPIOCR = (SYSTEM->VTPIOCR) | 0x00002000;
// Check VTP READY Status
while( !(SYSTEM->VTPIOCR & 0x8000)); // Set bit VTP_IOPWRDWN bit 14 for DDR input buffers)
//SYSTEM->VTPIOCR = SYSTEM->VTPIOCR | 0x00004000; // Set bit LOCK(bit7) and PWRSAVE (bit8)
SYSTEM->VTPIOCR = SYSTEM->VTPIOCR | 0x00000080; // Powerdown VTP as it is locked (bit 6)
// Set bit VTP_IOPWRDWN bit 14 for DDR input buffers)
SYSTEM->VTPIOCR = SYSTEM->VTPIOCR | 0x00004040;
// Wait for calibration to complete UTIL_waitLoop( 150 );
// Set the DDR2 to synreset, then enable it again
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_SYNCRESET);
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_ENABLE);
DDR->DDRPHYCR = 0x000000C5;
DDR->SDBCR = 0x534832;
DDR->SDBCR = 0x53C832; // 0x53C832; Set the TIMUNLOCK to write into the TMR reg
DDR->SDBCR = 0x53C832; // 0x53C832; Set the TIMUNLOCK to write into the TMR reg
DDR->SDTIMR = 0x57B57D98;
DDR->SDTIMR2 = 0x542EC743;
DDR->SDTIMR2 = 0x542EC743;
DDR->SDBCR = 0x134832; //0x534832; Reset the TIMUNLOCK TMR Write Disable
DDR->PBBPR = 0x000000FE;
DDR->SDBCR = 0xD34A32; //Enable DDR2 and DDR and SDram. Write '1' to BOOTUNLOCK
DDR->SDBCR = 0xD34A32; //Enable DDR2 and DDR and SDram. Write '1' to BOOTUNLOCK
DDR->SDBCR = 0x534A32; //Enable DDR2 and DDR and SDram. Write '0' to BOOTUNLOCK
DDR->SDRCR = (DDR_RR * DDR_FREQ) / 10; //Program SDRAM Refresh Control Registers
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_SYNCRESET);
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_ENABLE);
DEVICE_LPSCTransition(LPSC_DDR2,0,PSC_ENABLE);
return E_PASS;
}
}
Chris Meng:
你好,
我觉得硬件问题的可能性大些。你能否检查一下DDR相关的电源?
feller shi:
回复 Chris Meng:
谢谢。补充信息:
DDR的电源也测量过了。
vref测量:0.9v
DDR的时钟测量了。
DDR_CKP/DDR_CKN都正常,示波器与设置的频率有点差异,估计是示波器的频率精度问题。
疑问:如果DDR供电有问题,那么DM368的控制器会无法送出DDR_CS,而可以送出DDR_CAS么?
:)