We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Hallo
Im using the LPC2478 with 8 MB external memory. Im setting up the SDRAM from within the LPC2400.s file.
Everything is OK, until a NORMAL command is issued to the SDRAM (Right after dummy read)
LDR R4, =NORMAL_CMD ; Write NORMAL Command STR R4, [R0, #EMC_DYN_CTRL_OFS]
The last code line, overwrittes the EMCDynamicCfg0 register with a value resulting in selection of a wrong SDRAM type. Before the call the EMCDynamicConfig0 is 0x00001280 After the line its 0x07664448 ???
The values in R4, R0 and #EMC_DYN_CTRL_OFS are just fine.
Why does that code write to my EMCDynamicConfig0 register? It schould write to the EMCDynamicControl register instead. But it writes to both with a corrupted value?
/Thomas
As much as I see, you have not ported this code 100%, for example where is a dummy read in your code?
I have found the reason.
The for-loop, thats makes a delay between the commands, was not long enough.
Setting those to the right ones it works fine.
By the way, I cant see any reason for the dummy read???
Embedded forums everywhere constantly warns about dumb for loops for delay - they regularly hurts.
You realize that an empty for loop can be totally omitted, so you can't even be sure that it is enough to increase the stop criteria.
Another thing - why don't you post code as code? It is way easier to read if you do, since all line breaks in the source will survive.
I know. So I have just used a timer for the job instead. So any delays can be made by calling the same function
Reason for dummy read is setting the mode register of the SDRAM as this is set by address lines after mode command is issued.
Usually timings are very important in initializations, the way you ensure that delays are as necessary are not really important, also calculating it roughly by using instructions should be satisfactory.