s3c6410 ddr初始化

初学ARM,将学习中的代码贴出,以便以后参考,错误之处欢迎指出

ok6410 sdram(256M)初始化代码

[plain]  view plain copy
  1. #define P1MEMSTAT   (*((volatile unsigned long *)0x7e001000))  
  2. #define P1MEMCCMD   (*((volatile unsigned long *)0x7e001004))  
  3. #define P1DIRECTCMD (*((volatile unsigned long *)0x7e001008))  
  4. #define P1MEMCFG    (*((volatile unsigned long *)0x7e00100c))  
  5.   
  6. #define P1REFRESH   (*((volatile unsigned long *)0x7e001010))  
  7. #define P1CASLAT    (*((volatile unsigned long *)0x7e001014))  
  8. #define P1T_DQSS    (*((volatile unsigned long *)0x7e001018))  
  9. #define P1T_MRD     (*((volatile unsigned long *)0x7e00101c))  
  10. #define P1T_RAS     (*((volatile unsigned long *)0x7e001020))  
  11. #define P1T_RC      (*((volatile unsigned long *)0x7e001024))  
  12. #define P1T_RCD     (*((volatile unsigned long *)0x7e001028))  
  13. #define P1T_RFC     (*((volatile unsigned long *)0x7e00102c))  
  14. #define P1T_RP      (*((volatile unsigned long *)0x7e001030))  
  15. #define P1T_RRD     (*((volatile unsigned long *)0x7e001034))  
  16. #define P1T_WR      (*((volatile unsigned long *)0x7e001038))  
  17. #define P1T_WTR     (*((volatile unsigned long *)0x7e00103c))  
  18. #define P1T_XP      (*((volatile unsigned long *)0x7e001040))  
  19. #define P1T_XSR     (*((volatile unsigned long *)0x7e001044))  
  20. #define P1T_ESR     (*((volatile unsigned long *)0x7e001048))  
  21. #define P1MEMCFG2   (*((volatile unsigned long *)0x7e00104c))  
  22. #define p1_chip_0_cfg   (*((volatile unsigned long *)0x7e001200))  
  23. #define MEM_SYS_CFG     (*((volatile unsigned long *)0x7e00f120))  
  24.   
  25. #define HCLK        133  
  26. #define nstoclk(ns) (ns / (1000/HCLK) + 1)  
  27.   
  28. void ddr_init(void)  
  29. {  
  30.     /*makes DRAM enter "config" state*/  
  31.     P1MEMCCMD = 0x04;  
  32.       
  33.     /*set memory timing parameter, chip config ,   
  34.       id config register,etc...  
  35.     */  
  36.     P1REFRESH = nstoclk(7800); //Auto refresh duty cycle=7.8us =>clock cycles  
  37.     P1CASLAT = (3 << 1);  
  38.     P1T_DQSS = 0X1;  
  39.     P1T_MRD = 0X2;  
  40.     P1T_RAS = nstoclk(45);  
  41.     P1T_RC = nstoclk(68);  
  42.     P1T_RCD = nstoclk(23);//| ((nstoclk(23)-3) << 3);   
  43.     P1T_RFC = nstoclk(80);//| ((nstoclk(80)-3)  << 5);      
  44.     P1T_RP = nstoclk(23);//| ((nstoclk(23)-3) << 3);    
  45.     P1T_RRD = nstoclk(15);  
  46.     P1T_WR = nstoclk(15);  
  47.     P1T_WTR = 0X7;  
  48.     P1T_XP = 0X2;  
  49.     P1T_XSR = nstoclk(120);  
  50.     P1T_ESR = nstoclk(120);  
  51.       
  52.     /*mem config*/  
  53.     P1MEMCFG |= 0x3;    //11 columns  
  54.   
  55.     P1MEMCFG &= ~(0xf << 3);  
  56.     P1MEMCFG |= (1 << 4); //13 rows , 256M  
  57.   
  58.     P1MEMCFG &= ~(0x7 << 15);  
  59.     P1MEMCFG |= (1 << 16); //burst 4  
  60.   
  61.     P1MEMCFG2 |= 0x5;  
  62.   
  63.     P1MEMCFG2 &= ~(0x3 << 6);  
  64.     P1MEMCFG2 |= (1 << 6);  //32bit  
  65.   
  66.     P1MEMCFG2 &= ~(0x7 << 8);  
  67.     P1MEMCFG2 |= (0x3 << 8);  
  68.   
  69.     P1MEMCFG2 &= ~(0x3 << 11);  
  70.     P1MEMCFG2 |= (1 << 11);  
  71.   
  72.     p1_chip_0_cfg |= 1 << 16;  
  73.   
  74.     P1DIRECTCMD = 0xc0000; //nop  
  75.     P1DIRECTCMD = 0x000;   //prechargeAII  
  76.     P1DIRECTCMD = 0x40000; //autorefresh   
  77.     P1DIRECTCMD = 0x40000;   
  78.     P1DIRECTCMD = 0xa0000; //MRS  
  79.     P1DIRECTCMD = 0x80032; //EMRS  
  80.       
  81.     MEM_SYS_CFG = 0X0;  
  82.       
  83.     /*set DRAM to "go" state*/  
  84.     P1MEMCCMD = 0x000;  
  85.       
  86.     /*wait for "ready" state*/  
  87.     while ((P1MEMSTAT & 0X3) != 0X1);  
  88. }     
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值