<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://community.arm.com/utility/feedstylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/developer/tools-software/tools/f/keil-forum/25632/emcdynamiccfg0-gets-overwritten</link><description> 
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</description><dc:language>en-US</dc:language><generator>Telligent Community 10</generator><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/146397?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 10:44:57 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:f2012c35-e1fc-4d69-8fca-3eb1b96ff50b</guid><dc:creator>while ();</dc:creator><description>&lt;p&gt;&lt;p&gt;
Reason for dummy read is setting the mode register of the SDRAM as
this is set by address lines after mode command is issued.&lt;/p&gt;

&lt;p&gt;
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.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/147528?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 07:00:02 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:a28a3fdf-e5f1-4a22-916f-45ec0adbfe8b</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
I know. So I have just used a timer for the job instead. So any
delays can be made by calling the same function&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/146396?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 06:53:47 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:34122b95-410e-4881-9158-d9d8d1b87b48</guid><dc:creator>ImPer Westermark</dc:creator><description>&lt;p&gt;&lt;p&gt;
Embedded forums everywhere constantly warns about dumb for loops
for delay - they regularly hurts.&lt;/p&gt;

&lt;p&gt;
You realize that an empty for loop can be totally omitted, so you
can&amp;#39;t even be sure that it is enough to increase the stop
criteria.&lt;/p&gt;

&lt;p&gt;
Another thing - why don&amp;#39;t you post code as code? It is way easier
to read if you do, since all line breaks in the source will
survive.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/144663?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 06:36:11 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:7988d40d-794e-4c13-a319-5136c496d4d9</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
I have found the reason.&lt;/p&gt;

&lt;p&gt;
The for-loop, thats makes a delay between the commands, was not
long enough.&lt;/p&gt;

&lt;p&gt;
Setting those to the right ones it works fine.&lt;/p&gt;

&lt;p&gt;
By the way, I cant see any reason for the dummy read???&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/142357?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 06:04:39 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:440d3b86-48b0-4067-857f-abdb34d1b4b5</guid><dc:creator>while ();</dc:creator><description>&lt;p&gt;&lt;p&gt;
As much as I see, you have not ported this code 100%, for example
where is a dummy read in your code?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/139228?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 05:53:18 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:09c1444c-b51c-4ae3-a627-4ffbf48e23df</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
Hallo&lt;/p&gt;

&lt;p&gt;
Do you mean the assembly of the compiled C source??&lt;/p&gt;

&lt;p&gt;
I have send the assembly code for the builded source:&lt;/p&gt;

&lt;p&gt;
64: // Wait 0 65: //wait 128 ABH clock cycles&lt;br /&gt;
0x0000054C E3A01D4A MOV R1,#0x00001280&lt;br /&gt;
0x00000550 E5801100 STR R1,[R0,#0x0100] 66: for(i=0; i&amp;lt;0x100;
i++); 67: //Send command: NOP&lt;br /&gt;
0x00000554 E3A01000 MOV R1,#0x00000000&lt;br /&gt;
0x00000558 E3510C01 CMP R1,#0x00000100&lt;br /&gt;
0x0000055C 2A000001 BCS 0x00000568&lt;br /&gt;
0x00000560 E2811001 ADD R1,R1,#0x00000001&lt;br /&gt;
0x00000564 EAFFFFFB B 0x00000558 68: EMC_DYN_CTRL = 0x00000183; 69:
70: // Wait 1 71: //wait 128 ABH clock cycles&lt;br /&gt;
0x00000568 E59F108C LDR R1,[PC,#0x008C]&lt;br /&gt;
0x0000056C E5801020 STR R1,[R0,#0x0020] 72: for(i=0; i&amp;lt;0x100;
i++); 73: //Send command: PRECHARGE-ALL, shortest possible refresh
period&lt;br /&gt;
0x00000570 E3A01000 MOV R1,#0x00000000&lt;br /&gt;
0x00000574 E3510C01 CMP R1,#0x00000100&lt;br /&gt;
0x00000578 2A000001 BCS 0x00000584&lt;br /&gt;
0x0000057C E2811001 ADD R1,R1,#0x00000001&lt;br /&gt;
0x00000580 EAFFFFFB B 0x00000574 74: EMC_DYN_CTRL = 0x00000103;&lt;br /&gt;
0x00000584 E59F1074 LDR R1,[PC,#0x0074]&lt;br /&gt;
0x00000588 E5801020 STR R1,[R0,#0x0020]&lt;/p&gt;

&lt;p&gt;
/Thomas&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/135844?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 05:33:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:c7fe807f-a84f-404f-b4a6-19e0f14c23be</guid><dc:creator>while ();</dc:creator><description>&lt;p&gt;&lt;p&gt;
Can you also post assembly code?&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/125556?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 05:06:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:659d5b73-d466-41c4-8bf5-65d523ab94eb</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
I have now tried to move the SDRAM init to C source.&lt;/p&gt;

&lt;p&gt;
And again, when the NOP command is issued the EMCDynamicConfig0
and EMCDynamicControl is messed up.!!!&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;&lt;br /&gt;
// SDRAM Init&lt;br /&gt;
PCONP |= 0x00000800; /* Turn on EMC PCLK */&lt;br /&gt;
EMC_CTRL = 0x00000001;&lt;br /&gt;
EMC_CONFIG = 0x00000000;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;PINSEL5 |= 0x05010115;&lt;br /&gt;
PINSEL6 |= 0x55555555; // D0-15&lt;br /&gt;
PINSEL8 = 0x05555555;&lt;br /&gt;
PINSEL9 = 0x50045555;//0x10040000;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;// Setup Dynamic Memory Interface&lt;br /&gt;
// 16 bit&lt;br /&gt;
EMC_DYN_RP = 2;&lt;br /&gt;
EMC_DYN_RAS = 3;&lt;br /&gt;
EMC_DYN_SREX = 7;&lt;br /&gt;
EMC_DYN_APR = 2;&lt;br /&gt;
EMC_DYN_DAL = 5;&lt;br /&gt;
EMC_DYN_WR = 1;&lt;br /&gt;
EMC_DYN_RC = 5;&lt;br /&gt;
EMC_DYN_RFC = 5;&lt;br /&gt;
EMC_DYN_XSR = 7;&lt;br /&gt;
EMC_DYN_RRD = 1;&lt;br /&gt;
EMC_DYN_MRD = 2;&lt;br /&gt;
EMC_DYN_RD_CFG = 1;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;EMC_DYN_RASCAS0 = 0x00000303;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;EMC_DYN_CFG0 = 0x00001280;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;// Wait 0&lt;br /&gt;
for(i=0; i&amp;lt;0x100; i++);&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;// ERROR OCCURES HERE!!!!&lt;br /&gt;
//Send command: NOP&lt;br /&gt;
EMC_DYN_CTRL = 0x00000183;&lt;br /&gt;
// ERROR END&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;// Wait 1&lt;br /&gt;
//wait 128 ABH clock cycles&lt;br /&gt;
for(i=0; i&amp;lt;0x100; i++); //Send command: PRECHARGE-ALL, shortest
possible refresh period&lt;br /&gt;
EMC_DYN_CTRL = 0x00000103;&lt;br /&gt;
EMC_DYN_RFSH = 0x00000002;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;// Wait 2&lt;br /&gt;
//wait 128 ABH clock cycles&lt;br /&gt;
for(i=0; i&amp;lt;0x40; i++);&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;//Set correct refresh period&lt;br /&gt;
EMC_DYN_RFSH = 0x1C;&lt;br /&gt;
//Send command: MODE&lt;br /&gt;
EMC_DYN_CTRL = 0x00000083;&lt;br /&gt;
//Send command: NORMAL&lt;br /&gt;
EMC_DYN_CTRL = 0x00000000;&lt;br /&gt;
//Enable buffer&lt;br /&gt;
EMC_DYN_CFG0 |= 0x00080000; //0x00001280&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
&lt;b&gt;//wait 128 ABH clock cycles&lt;br /&gt;
for(i=0; i&amp;lt;0x10; i++);&lt;br /&gt;&lt;/b&gt;&lt;/p&gt;

&lt;p&gt;
The line &amp;quot;EMC_DYN_CTRL = 0x00000183&amp;quot;, which schould write 0x183 to
the EMCDynamicCOntrol register. But watching the External Memory
Controller debug view in Keil, then the value 0x058C4448 is written
to the EMCDynamicConfig0 and EMCDynamicControl register???&lt;/p&gt;

&lt;p&gt;
Why?&lt;/p&gt;

&lt;p&gt;
Thomas&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/115052?ContentTypeID=1</link><pubDate>Thu, 02 Jul 2009 01:12:00 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:98951792-e988-4faf-b23e-774b78e40802</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
I did. The startup file is from the lat&amp;Atilde;&amp;laquo;st Blinky
sample from Keil!!!&lt;/p&gt;

&lt;p&gt;
/Thomas&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/103243?ContentTypeID=1</link><pubDate>Wed, 01 Jul 2009 23:24:17 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:edc306ba-2a07-49e8-b86c-9b5096d7453d</guid><dc:creator>while ();</dc:creator><description>&lt;p&gt;&lt;p&gt;
My guess is that you are not doing same thing in startup as in C,
no other explanation is possible.&lt;br /&gt;
So, investigate starup, perhaps you are not setting the mode register
in startup or something.&lt;br /&gt;
Also, use the last available example from Keil for starting
point.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/77548?ContentTypeID=1</link><pubDate>Wed, 01 Jul 2009 23:19:49 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:8855e29a-8d98-48bc-a799-3da8c478ec7a</guid><dc:creator>Thomas Johansen</dc:creator><description>&lt;p&gt;&lt;p&gt;
If I do it in C, it works fine. The setup was in my startup file,
so I would like to use that instead.&lt;br /&gt;
I just couldnt understand why it doesnt works!??&lt;/p&gt;

&lt;p&gt;
/Thomas&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: EMCDynamicCfg0 gets overwritten?</title><link>https://community.arm.com/thread/56354?ContentTypeID=1</link><pubDate>Wed, 01 Jul 2009 22:31:58 GMT</pubDate><guid isPermaLink="false">dd9e70c8-6d3c-4c71-b136-2456382a7b5c:16afcfca-79cf-4429-8219-2df071b53535</guid><dc:creator>while ();</dc:creator><description>&lt;p&gt;&lt;p&gt;
Try initializing SDRAM with script (Ext_RAM.ini) and see if you
can get it to initialize correctly and if you have the same
problem.&lt;/p&gt;
&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>