Hi! ich habe hier ein Board mit einem Atmel SAM9 drauf und SDRAM (16MB, 32Bit). Es ist kein Entwicklungsbord,ein bekannter hatte noch welche und da hab ich eins zum spielen abstauben können. Er meint Hardwareseitig sei alles in Ordnung. Jetzt hab ich mich direkt mal ran gemacht und ist soweit auch gut schnell ABER: Wenn ich in der Software das SDRAM auf 16Bit stelle und ein Array of Byte/Short/Int anlege, das von 1..200 beschreibe (also index [1]=2,[2]=3..) und mir das im Debugger anschaue, habe ich auch immer genau exakt diese Werte im SDRAM stehen. Wenn ich jetzt auf 32Bit stelle, habe ich irgendwie matsch. Short Werte sind statt (0x20000000)=0001 (0x20000001)=0002 (0x20000001)=0003 (16Bit) (0x20000000)=0001 (0x20000001)=0001 (0x20000002)=0002 (0x20000003)=0002 also an Index [0] ist bei 16Bit die 1, bei 32Bit auch. An Index [1] ist bei 16Bit die 2 (korrekterweise), bei 32Bit aber wieder [0]. Es ist bei 32Bit immer doppelt vorhanden. Byte Werte sind ganz komisch angeordnet, Integer Werte stimmen aber... Wenn ich ein kleines Blink PRogramm ins SDRAM lade, dann läuft das aber... Ist vielleicht bei der Konfig was falsch? (Column=8, Rows=12, Bank=4, CAS=2, Bus=32Bit, TWR=2, TRC=7, TRP=2, TRCD=2, TRAS=5, TXSR=8). Refresh Counter = 207 Takt ist 118MHz intern und MCK = CPU / 4 also 29MHz (testweise). 29MHz dann auch SDRAM Clock. 2 von den RAM Bausteinen sind drauf: http://fp.cse.wustl.edu/cse362/Datasheets/sdram.pdf Beschaltung ist so wie im Datenblatt vom SAM9 als Beispiel angegeben. Danke!
thomas wrote: > (0x20000000)=0001 (0x20000001)=0002 (0x20000001)=0003 (16Bit) Dass ein 16bit Wert 2 Bytes braucht, also die Adressen 0x20000000,0x20000002,0x20000004 zu erwarten wären, ist dir klar? > (0x20000000)=0001 (0x20000001)=0001 (0x20000002)=0002 > (0x20000003)=0002 Und dass ein 32bit Wert 4 Bytes beansprucht auch?
Ja das ist schon klar.. War von mir falsch geschrieben. also folgendermaßen: Datentyp Byte (8Bit) Busbreite 16Bit: (0x20000000) = 00 01 02 03 (0x20000004) = 04 05 06 07 (0x20000008) = 08 09 0A 0B Busbreite 32Bit: (sonst alles Identisch außer Busbreite-Konfiguration) (0x20000000) = 00 02 01 03 (0x20000004) = 04 06 05 07 (0x20000008) = 08 0A 09 0B Datentyp Short (16Bit) Busbreite 16Bit: (0x20000000) = 0001 0002 (0x20000004) = 0003 0004 (0x20000008) = 0005 0006 Busbreite 32Bit: (sonst alles Identisch außer Busbreite-Konfiguration) (0x20000000) = 0001 0001 (0x20000004) = 0002 0002 (0x20000008) = 0003 0003 Datentyp Integer (32Bit) Busbreite 16Bit: (0x20000000) = 00000001 (0x20000004) = 00000002 (0x20000008) = 00000003 Busbreite 32Bit: (sonst alles Identisch außer Busbreite-Konfiguration) (0x20000000) = 00000001 (0x20000004) = 00000002 (0x20000008) = 00000003 Code:
1 | unsigned char abc[512]; |
2 | |
3 | for(y = 0; y < 512; y++) |
4 | { abc[y] = y; } |
Wirst wohl nicht darum herumkommen, etwas mehr Info rauszurücken.
- Typ des Controllers ("SAM9" ist eine Familie)
- die exakte Schaltung (Bild, ggf. Datasheet Fig XX)
- den Code.
Also der Code steht im Prinzip schon oben. Ist eine Main() Routine die eben das Array füllt und dann in einer while(1) Schleife landet.Man fängt ja klein an ;) Controller drauf ist ein Atmel AT91SAM9260QU PQFP. SDRAMs sind von MT 48LC4M16A2-7E G (2 Stück). Schaltung ist die im Atmel Datenblatt (http://www.atmel.com/dyn/resources/prod_documents/doc6221.pdf)auf Seite 158. Startup-File ist das von Keil, konfiguriert über den Optionsreiter. Mich wundert einfach, das 32Bit Werte korrekt gespeichert werden, die anderen aber nicht...
Mit dem Code war der von der Initialisierung des Speichercontrollers gemeint.
Ah ok.. wie gesagt stammt von Keil:
;----------------------- SDRAM Controller (SDRAMC) Definitions
-----------
; SDRAM Controller (SDRAMC) User Interface
SDRAMC_BASE EQU 0xFFFFEA00 ; SDRAMC Base
Address
SDRAMC_MR_OFS EQU 0x00 ; Mode Register Address
Offsett
SDRAMC_TR_OFS EQU 0x04 ; Refresh Timer Register Address
Offsett
SDRAMC_CR_OFS EQU 0x08 ; Configuration Register Address
Offsett
SDRAMC_HSR_OFS EQU 0x0C ; High Speed Register Address
Offsett
; Constants
CMD_NORMAL EQU 0x00 ; SDRAM Normal Mode
CMD_NOP EQU 0x01 ; SDRAM NOP Command
CMD_PRCGALL EQU 0x02 ; SDRAM All Banks Precharge
Command
CMD_LMR EQU 0x03 ; SDRAM Load Mode Register
Command
CMD_RFSH EQU 0x04 ; SDRAM Refresh Command
;// <e> SDRAM Controller (SDRAMC)
SDRAMC_SETUP EQU 1
;// <h> Refresh Timer Register (SDRAMC_TR)
;// <o0.0..11> COUNT: SDRAMC Refresh Timer Count <0-4095>
;// <i> This 12-bit field is loaded into a timer that
generates
;// <i> the refresh pulse
;// </h>
SDRAMC_TR_Val EQU 0x000000CF
SDRAMC_CR_Val EQU 0x852272D4
;// <h> High Speed Register (SDRAMC_HSR)
;// <o0.0> DA: Decode Cycle Enable
;// </h>
SDRAMC_HSR_Val EQU 0x00000000
[..]
; Setup SDRAM Controller if enabled
IF :DEF:NO_SDRAM_INIT
ELSE
IF SDRAMC_SETUP != 0
; Setup Parallel Input/Output C Registers
; for driving SDRAM lines
LDR R0, =PIOC_BASE
LDR R1, =0xFFFF0000
STR R1, [R0, #PIO_PDR_OFS]
LDR R0, =SDRAMC_BASE
LDR R2, =EBI_CS1_ADDRESS
MOV R3, #0
; Setup Control Register of SDRAM Controller
LDR R1, =SDRAMC_CR_Val
STR R1, [R0, #SDRAMC_CR_OFS]
; Write All Banks Precharge Command to SDRAM
MOV R1, #CMD_PRCGALL
STR R1, [R0, #SDRAMC_MR_OFS]
STR R3, [R2, #0]
MOV R1, #1000 ; Number of cycles to
delay
Wait_SDRAMC SUBS R1, R1, #1
BNE Wait_SDRAMC
; Provide 8 Auto Refresh to SDRAM
MOV R1, #CMD_RFSH
STR R1, [R0, #SDRAMC_MR_OFS]; Set 1 CBR
MOV R3, #0x01
STR R3, [R2, #0x04] ; Perform CBR
STR R1, [R0, #SDRAMC_MR_OFS]; Set 2 CBR
MOV R3, #0x02
STR R3, [R2, #0x08] ; Perform CBR
STR R1, [R0, #SDRAMC_MR_OFS]; Set 3 CBR
MOV R3, #0x03
STR R3, [R2, #0x0C] ; Perform CBR
STR R1, [R0, #SDRAMC_MR_OFS]; Set 4 CBR
MOV R3, #0x04
STR R3, [R2, #0x10] ; Perform CBR
STR R1, [R0, #SDRAMC_MR_OFS]; Set 5 CBR
MOV R3, #0x05
STR R3, [R2, #0x14] ; Perform CBR
STR R1, [R0, #SDRAMC_MR_OFS]; Set 6 CBR
MOV R3, #0x06
STR R3, [R2, #0x18] ; Perform CBR
STR R1, [R0, #SDRAMC_MR_OFS]; Set 7 CBR
MOV R3, #0x07
STR R3, [R2, #0x1C] ; Perform CBR
STR R1, [R0, #SDRAMC_MR_OFS]; Set 8 CBR
MOV R3, #0x08
STR R3, [R2, #0x20] ; Perform CBR
; Write a Load Mode Register Command to SDRAM
MOV R1, #CMD_LMR
STR R1, [R0, #SDRAMC_MR_OFS]; Set LMR Operation
LDR R3, =0xCAFEDEDE
STR R3, [R2, #0x24] ; Perform LMR Burst
; Setup Refresh Timer Register
LDR R1, =SDRAMC_TR_Val
STR R1, [R0, #SDRAMC_TR_OFS]
STR R3, [R2, #0]
; Enter Normal Mode
MOV R1, #CMD_NORMAL
STR R1, [R0, #SDRAMC_MR_OFS]
; Setup Other SDRAM Controller Registers
LDR R1, =SDRAMC_HSR_Val
STR R1, [R0, #SDRAMC_HSR_OFS]
ENDIF
ENDIF ; of IF :DEF:NO_SDRAM_INIT
Die Parameter, die ich im Konfigurationsfenster angegeben habe, stehe ja
schon weiter oben..
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.