I am using LPC1788 and have successfully written EMC code. H57V2562GTR (SDRAM 16Mx16) is interfaced with the controller. Two ICs are used in parallel to write 32Bytes (16MSB in one chip and 16LSB in other). I have tested the code and it works fine (The read and write operations).
I know that by using __attribute__((at(address))) i can define variables at specific memory address.
Will i have to initialize the EMC before defining the variables in the external memory area?
That question really makes no sense, because there is no such quality as "before defining the variables" --- at least none that initializing the EMC could possibly, ever have. You define variable before you run the compiler, but you only initialize the EMC at run time, which is forcibly later.
What you have to do is initialize your memory subsystem to a workable state before your code accesses those variables in any way --- and because the first such access is likely the initialization performed by the startup code, that tends to mean you have to do that inside the startup code. The alternative is to mark those variables as "not to be initialized by start-up code" and delay the initial write until you're done initializing the memory subsystem.
Add the regions in your target dialog, or scatter file. Then you can specify the segment rather than having to explicitly manage the address space, ie let the linker do it's job.
Add code in your startup.s file to initialize your external memory prior to calling __main, which is Keil's routine to copy/clear the static areas prior to calling your main() function.
Thanks Westonsupermare Pier for answering. I will investigate and post my results.
Thanks Westonsupermare Pier for answering. I will investigate and post my results. Not my comment. some one has been using my name.
Add code in your startup.s file to initialize your external memory prior to calling __main, which is Keil's routine to copy/clear the static areas prior to calling your main() function. I was doubtful about the technique. but now that doubt is cleared, will go with it. But do i still have to use __attribute__? if no, then what is the other way around to let the compile know that 0xA0000000-0xAFFFFFFF memory area is available for allocation?