软件可编程的大小端模式;
地址空间:每个BANK可寻址128MB(总共8个BANK 1GB空间);
可编程的访问位宽:BANK0为16或32位,其他BANK为8或16或32位;
8个存储器BANK,其中6个用于ROM或者SRAM,2个用于ROM、SRAM或者SDRAM;
BANK0~BANK6的起始地址固定;
BANK7的起始地址和大小可编程;
所有存储器BANK的访问周期可编程;
外部wait信号可延长总线周期;
支持SDRAM的自刷新和掉电模式。
BANK0总线宽度由OM[1:0]引脚决定,当OM[1:0]=01时,booting ROM datawidth是16位,当[1:0]=10时,booting ROM datawidth是32位,当OM[1:0]=00时,从NAND FLASH启动。在友善之臂S3C2440开发板上,OM1引脚直接接地。
依据这张表,可以查找到SDRAM的BANK选择引脚连接方式,比如,我们使用的SDRAM是2片HYNIX的HY57V561620(L)T,它的规格是4*4M*16bit(使用两片是为了配置成32位的总线宽度),BANK大小是4M*16=64MB,总线宽度是32位,器件大小是4*BANK大小=256Mb,寄存器配置就是(4M*16*4B)*2,根据上面的表格,SDRAM上的BANK地址引脚(BA[1:0])与S3C2440的A[25:24]相连。
上表是寄存器控制地址总线连接方式,我们使用2片SDRAM配置成32位的总线宽度,所以SDRAM上的A[12:0]接到S3C2440的A[14:2]引脚。
具体的S3C2440与两片SDRAM接线方式如下图所示:
SDRAM的工作时序作为ARM工程师了解即可,具体的读写控制由CPU自带的控制寄存器完成,而作为FPGA工程师则需要详细了解SDRAM工作原理与时序,在此不再赘述。作为ARM工程师,最重要的是准确配置与SDRAM相关的寄存器。
在系统使用SDRAM之前,需要对S3C2440的存储器控制器进行初始化。其中对与SDRAM(Bank6)相关的寄存器进行了特殊的设置,以使SDRAM能够正常工作。由于C语言程序使用的数据空间和堆栈空间都定位在SDRAM上,因此,如果没有对SDRAM(Bank6)的正确初始化,系统就无法正确启动。下面介绍与SDRAM相关的寄存器设置。
1、 总线宽度&等待控制寄存器(BWSCON)0x48000000
在这个寄存器中,可以配置BANK1~BANK7的DW、WS、ST,DW决定了数据总线宽度;WS是等待状态是否使能,如果此位为1,WAIT信号可以用于延长nOE信号的有效时间;ST决定是否使用UB/LB(与SRAM相关)。此寄存器还可以读取(注意对Bank0只能读取不能写)BANK0的数据总线宽度。
对于SDRAM,只需要设置BANK6和BANK7的DW相关位,此处设置为32位。
BWSCON(0x48000000)=0x22xxxxxx,后面的24位设置和FLASH有关,一个例子是设置为0x22111120。
2、 BANK控制寄存器(BANKCONN)
BANK0~BANK5的控制寄存器相同,复位值均为0x0700。
包括对Tacs(nGCSn前的地址建立时间)、Tcos(nOE信号有效前的片选建立时间)、Tacc(访问周期,当WAIT使能时,Tacc必须大于等于4个时钟周期)、Tcoh(nOE后的片选保持时间)、Tcah(nGCSn后的地址保持时间)、Tacp(Page模式下的访问周期)、PMC(Page模式配置)。
BANK6、BANK7的控制寄存器相同。如果存储器类型为ROM或者SRAM,情况与BANK0~BANK5类似,如果存储器类型为SDRAM,则需要设置Trcd(RAS到CAS的延时)和SCAN(列地址位数),
根据我们使用的SDRAM以及S3C2440的HCLK(SDRAM时钟由系统的HCLK提供)时钟情况,Trcd取3个时钟,列地址位数是9,则BANKCON6(0x4800001C)=0x00018005,
BANKCON7(0x48000020)=0x00018005。
3、 SDRAM刷新控制寄存器(REFRESH)
包括REFEN位(刷新使能位),此位一般设置为1;TREFMD位(SDRAM刷新模式),初始值为0;Trp(SDRAM RAS预充电时间),此位需要根据时钟HCLK与选用的SDRAM芯片决定,一般设置为2或3个时钟;Tsrc位(SDRAM半行周期时间),由Trc-Trp得到,Trc和Trp的值由时钟和SDRAM芯片决定;REFRESH COUNTER位(SDRAM刷新计数值),刷新计数值=2^11+1-HCLK*SDRAM刷新时间(刷新时间参考S3C2440和SDRAM技术手册)。
4、 BANK SIZE寄存器(BANKSIZE)
BURST_EN位是ARM核突发模式使能位,设为0或1均可,为了提高效率,此处可以设为1;SCKE_EN,SDRAM掉电模式使能控制,设为1;SCLK_EN,设为1,SCLK仅在访问周期才被激活;BK76MAP,BANK6和BANK7的内存映射,我们使用2片4B*4M*16bit的SDRAM组成32位256MB存储器,而且BANK6和BANK7大小要相等,所以此处设为2,即128MB/128MB。BANKSIZE(0x48000028)=0x000000B2。
5、 SDRAM模式寄存器集合寄存器(MRSR)
WBL位,突发写长度,一般设为0,突发写长度固定;TM位,测试模式,一般设为00,模式寄存器集合(固定);CL位,CAS延时,根据SDRAM芯片和HCLK时钟计算;BT位,突发类型,一般设为0,连续的(固定);BL位,突发长度,一般设为000(固定的)。MRSR(0x4800002C)=0x00000030,(0x48000030)=0x00000030。
ARM9(S3C2440)的13个存储控制寄存器
2009-04-29 21:45
内存控制器地址,摘自三星技术手册:
BWSCON 0x48000000 R/W Bus Width & Wait Status Control BANKCON0 0x48000004 Boot ROM Control BANKCON1 0x48000008 BANK1 Control BANKCON2 0x4800000C BANK2 Control BANKCON3 0x48000010 BANK3 Control BANKCON4 0x48000014 BANK4 Control BANKCON5 0x48000018 BANK5 Control BANKCON6 0x4800001C BANK6 Control BANKCON7 0x48000020 BANK7 Control REFRESH 0x48000024 DRAM/SDRAM Refresh Control BANKSIZE 0x48000028 Flexible Bank Size MRSRB6 0x4800002C Mode register set for SDRAM BANK6 MRSRB7 0x48000030 Mode register set for SDRAM BANK7
BWSCON,共32位:
31~28:BANK7 27~24:BANK6 。。。。。 3~0:BANK0
BANK7~BANK1设置一致
四位分别代表: STx:和树上说的不一样,手册说表示 SRAM for using UB/LB ,0不使用,1使用,一般接0 WSx :是否插入等待信号,0否,1是,一般选0 DWx(2位):00 8位,01 16位,10 32位,11 保留。这个每一个BANK可以根据书上 P91页表格看BANK的宽度。
BANK0比较特殊, 3:保留,写0 2~1(只读):取00,由硬件决定,因为你写不进去东西。。 0:保留,取0 总之BANK0就是0000(2进制)就对了
由此就得来了,这块板子上,0x22011110
BANKCON0~5(对应BANK 0~5,每个寄存器32位):保留值,写入0x00000700即可。
BANKCON6~7(对应BANK 6~7,每个寄存器32位):
31~17位,设为0
16~15,11表示BANKx接了SDRAM,00 SRAM,我的开发板BANK6接的是SRAM当然是11了
如果是SRAM就按照上面的000700就好了,如果是SDRAM,只需要设置3~0
3~2:CAS用几个周期,推荐为3个周期,01 1~0:列信号有几根线。。 mini2440的SDRAM芯片是HY57V561620(L)T, 光盘里的pdf手册显示了如下内容:Column Address : CA0 ~ CA8,因此是9根,所以取01 综上,BANKCON6~7的取值为 0x00018005
REFRESH(32位,用于设定SDRAM的刷新):
23:是否开启SDRAM刷新,自然选1开启 22:SDRAM刷新模式,选0 21~20:取00或者10,RAS的change时间 19~18:行时间,取11 17~11:0
10~0:就是刷新频率了~~
计算公式,R_CNT=2^11+1-SDRAM时钟频率(Mhz)*SDRAM刷新周期(uS)
HY那个手册上写到:8192个刷新周期用64ms,因此刷新周期=64000/8192=7.8125 时钟频率有好多种啊,先实验为100Mhz的吧。。
因此计算出来就是1267.75,四舍五入1268->0x04f4
因此这个REFRESH取值是 0x008c04f4,简单计算方法就是0x008c0000 + 04f4
BANKSIZE(32为寄存器):
支持核突发,使用SCKE,仅在SDRAM期间发出SCLK,地址空间64Mb 因此BANKSIZE为 0x000000B1
MRSRB6~7(SDRAM模式设置)
3个时钟周期,0x30 |
The S3C2410X has 117 multi-functionalinput/output port pins. The ports are:
— Port A (GPA): 23-output port
— Port B (GPB): 11-input/output port
— Port C (GPC): 16-input/output port
— Port D (GPD): 16-input/output port
— Port E (GPE): 16-input/output port
— Port F (GPF): 8-input/output port
— Port G (GPG): 16-input/output port
— Port H (GPH): 11-input/output port
---PORT A 23-output
GPACON 0x56000000
GPADAT 0x56000004
---PORT B 11-input/output
GPBCON 0x56000010
GPBDAT 0x56000014
GPBUP 0x56000018
---PORT C 16-input/output
GPCCON 0x56000020
GPCDAT 0x56000024
GPCUP 0x56000028
---PORT D 16-input/output
GPDCON 0x56000030
GPDDAT 0x56000034
GPDUP 0x56000038
---PORT E 16-input/output
GPECON 0x56000040
GPEDAT 0x56000044
GPEUP 0x56000048
---PORT F 8-input/output
GPFCON 0x56000050
GPFDAT 0x56000054
GPFUP 0x56000058
---PORT G 16-input/output
GPGCON 0x56000060
GPGDAT 0x56000064
GPGUP 0x56000068
---PORT H 11-input/output
GPHCON 0x56000070
GPHDAT 0x56000074
GPHUP 0x56000078
NAND 寄存器
2009-05-24 13:02
NFCONF 0x4E000000 R/W NAND Flash configuration
[15] Enable/Disable After auto-boot, this bit is cleared to 0 automatically. For the access to the NAND flash memoty, this bit must be set. [14:13] Reserbed [12] Initialize ECC [11] NAND Flash Memory chip enable 0:nFCE=L(active), 1:nFCE=H [10:8] TACLS [7] [6:4] TWRPH0 [3] [2:0] TWRPH1 NFCMD 0x4E000004 R/W NAND flash command set register [7:0] CMD NAND Flash memory command value NFADDR 0x4E000008 R/W NAND flash address set register [7:0] Address NAND flash memory address value NFDATA 0x4E00000C R/W NAND flash data register [7:0] Data Nand flsh read/program data value NFSTAT 0x4E000010 R NAND Flash operation status [0] RnB 0:NAND Flash memory busy 1:NAND Flash memory ready to operate NFECC 0x4E000014 R NAND Flash ECC (Error Correction Code) register [23:16] Error Correction Code #2 [15:8] #1 [7:0] #0 |
PWM Timer 寄存器
2009-05-24 16:59
PWM TIMER TCFG0 0x51000000 R/W Configures the two 8-bit prescalers TCFG1 0x51000004 R/W 5-MUX & DMA mode selecton register TCON 0x51000008 R/W Timer control register TCNTB0 0x5100000C R/W Timer 0 count buffer register TCMPB0 0x51000010 R/W Timer 0 compare buffer register TCNTO0 0x51000014 R Timer 0 count observation register TCNTB1 0x51000018 R/W Timer 1 count buffer register TCMPB1 0x5100001C R/W Timer 1 compare buffer register TCNTO1 0x51000020 R Timer 1 count observation register TCNTB2 0x51000024 R/W Timer 2 count buffer register TCMPB2 0x51000028 R/W Timer 2 compare buffer register TCNTO2 0x5100002C R Timer 2 count observation register TCNTB3 0x51000030 R/W Timer 3 count buffer register TCMPB3 0x51000034 R/W Timer 3 compare buffer register TCNTO3 0x51000038 R Timer 3 count observation register TCNTB4 0x5100003C R/W Timer 4 count buffer register TCNTO4 0x51000040 R Timer 4 count observation register TCFG0 0x51000000 R/W Configures the two 8-bit prescalers [23:16] Dead zone length [15: 8] Prescaler 1 These 8 bits determine prescaler value for Timer 2, 3 and 4. [ 7: 0] Prescaler 1 for Timer 1 and 0. TCFG1 0x51000004 R/W 5-MUX & DMA mode selecton register [23:20] DMA mode Select DMA: 0000=NoSelect; 0001=Timer0; 0010=Timer1; 0011=Timer2; 0100=Timer3; 0101=Timer4; 0110=Reserved [19:16] MUX4 Select MUX input for PWM Timer4:0000=1/2;0001=1/4;0010=1/8; 0011=1/16; 01xx=External TCLK1 [15:12] MUX3 for Timer3 [11: 8] MUX2 for Timer2 [ 7: 4] MUX1 for Timer1 [ 3: 0] MUX0 for Timer0 TCON 0x51000008 R/W Timer control register [22] Timer 4 auto reload on/off 0=One-shot 1=Interval mode(auto reload) [21] Timer 4 manual update 0=No operation 1=Update TCNTB4 [20] Timer 4 start/stop 0=Stop 1=Strat for Timer 4 [19] Timer 3 auto reload on/off [18] Timer 3 output inverter on off 0=Inverter off 1=Inverter on for TOUT3 [17] Timer 3 manual update [16] Timer 3 start/stop [15] [14] [13] [12] [11] [10] [9] [8] Timer 1 start/stop [7:5] Reserved [4] Dead zone enable [3] Timer 0 auto reload on/off [2] Timer 0 output inverter on/off [1] Timer 0 manual update [0] Timer 0 start/stop TCNTB0 0x5100000C R/W Timer 0 count buffer register [15:0] Timer 0 count buffer register TCMPB0 0x51000010 R/W Timer 0 compare buffer register [15:0] Timer 0 compare buffer register TCNTO0 0x51000014 R Timer 0 count observation register [15:0] Timer 0 observation register (计数观察寄存器) TCNTB1 0x51000018 R/W Timer 1 count buffer register TCMPB1 0x5100001C R/W Timer 1 compare buffer register TCNTO1 0x51000020 R Timer 1 count observation register TCNTB2 0x51000024 R/W Timer 2 count buffer register TCMPB2 0x51000028 R/W Timer 2 compare buffer register TCNTO2 0x5100002C R Timer 2 count observation register TCNTB3 0x51000030 R/W Timer 3 count buffer register TCMPB3 0x51000034 R/W Timer 3 compare buffer register TCNTO3 0x51000038 R Timer 3 count observation register TCNTB4 0x5100003C R/W Timer 4 count buffer register TCNTO4 0x51000040 R Timer 4 count observation register |
WATCHDOG TIMER
2009-05-24 18:35
WATCHDOG TIMER OVERVIEW The S3C2440A watchdog timer is used to resume the controller operation whenever it is disturbed by malfunctions such as noise and system errors. It can be used as a normal 16-bit interval timer to request interrupt service. The watchdog timer generates the reset signal for 128 PCLK cycles. t_watchdog = 1/[ PCLK / (Prescaler value + 1) / Division_factor ] Once the watchdog timer is enabled, the value of watchdog timer data (WTDAT) register cannot be automatically reloaded into the timer counter (WTCNT). In this reason, an initial value must be written to the watchdog timer count (WTCNT) register, before the watchdog timer starts. When the S3C2440A is in debug mode using Embedded ICE, the watchdog timer must not operate. The WTCON register allows the user to enable/disable the watchdog timer, select the clock signal from 4 different sources, enable/disable interrupts, and enable/disable the watchdog timer output. The Watchdog timer is used to resume the S3C2440A restart on mal-function after its power on; if controller restart is not desired, the Watchdog timer should be disabled. If the user wants to use the normal timer provided by the Watchdog timer, enable the interrupt and disable the Watchdog timer. WTCON 0x53000000 R/W Watchdog timer control register 0x8021 [15:8] Prescaler value 0--255 [5] Watchdog timer. Enable or disable bit of Watchdog timer. [4:3] Clock select. Determine the clock division factor. 00=16;01=32;10=64;11=128 [2] Interrupt generation. Enable or disable bit of the interrupt. 0=Disable;1=Enable [0] Reset enable/disable. Enable or disable bit of watchdog timer output for reset signal. 1=Assert reset signal of the S3C2440A at watchdog time-out 0=Disable the reset function of the watchdog timer. WTDAT 0x53000004 R/W Watchdog timer data register 0x8000 [15:0] Count reload value WTCNT 0x53000008 R/W Watchdog timer count register 0x8000 [15:0] Count value |
S3C2440 IO口寄存器地址
2009-05-10 00:26
S3C2440 IO口寄存器地址 GPACON:0x56000000,默认7FFFFF GPADAT:0x56000004 GPA0:ADDR0 GPA1~GPA11:ADDR16~ADDR26 GPA12~GPA16: nGCS1~nGCS5 GPA17 CLE GPA18 ALE GPA19 nFWE GPA20 nFRE GPA21 nRSTOUT GPA22 nFCE GPBCON:0x56000010,默认0x0 GPBDAT:0x56000014, GPBUP:0x56000018,默认0x0 GPB0~GPB3:TOUT0~TOUT3 GPB4 TCLK0 GPB5 nXBACK GPB6 nXBREQ GPB7 nXDACK1 GPB8 nXDREQ1 GPB9 nXDACK0 GPB10 nXDREQ0 GPCCON 0x56000020 GPCDAT 0x56000024 GPCUP 0x56000028 GPC0 LEND GPC1 VCLK GPC2 VLINE GPC3 VFRAME GPC4 VM GPC5 LCDVF0 GPC6 LCDVF1 GPC7 LCDVF2 GPC8~GPC15 VD0~VD7 GPFCON 0x56000050 GPFDAT 0x56000054 GPFUP 0x56000058 GPB0~GPB7 EINT0~EINT7 |