4
\$\begingroup\$

I have a project in mind. I want to buy an LPC2294 microcontroller, SDRAM IC, and flash IC (those IC's haven't yet been defined). What I want to do is connect those ICs to the microcontroller in order to expand its Program memory and data memory automatically (which means that I don't want to have to create a method to write on the flash or SDRAM, I want the microcontroller to be able to tell that it has those resources, and use them as if they were the microcontroller's on chip memories).

I know how to connect those components physically (since NXP's site has an example of this which was really easy to understand).

My main question: Is it only necessary to connect it via hardware and put LOW or HIGH on some pins on boot for the microcontroller to recognize those external resources as its own, or will I also have to do something else? For example: will I have to alter the memory registers that point to the internal flash and RAM and make those registers point to the external components? How would I be able to put the program on the external flash?

Would I have to write a bootloader and record it manually on theexternal flash or can I just use the internal bootloader, and somehow map it to the external devices?

If someone could explain this to me I would be really grateful. And if there's some code involved, or changes to the configuration files, could you please give me an example of how it works?

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

First you should verify whether you mean SDRAM or SRAM. I don't think this microcontroller supports SDRAM and I suspect you should plan to use an external SRAM.

Refer to the microcontroller documentation for examples on how to connect the microcontroller to the external SRAM and flash. You could also find an evaluation board that contains external memories and reference the eval board's schematic.

You will need to configure the microcontroller's External Memory Controller in order for the microcontroller to be able to use the external memories. Refer to the microcontroller's User Guide for details on how to configure the External Memory Controller. Basically each memory will be associated with a chip select pin and you will have to configure all the settings associated with the chip selects that you are using. Typically the External Memory Controller gets configured with some instructions in the startup code for your application. (It's configured by the startup code so that the external memories are accessible sooner rather than later.) You will likely have to provide, or at least customize, this portion of the startup code. Here again, if you can find an eval board with external memories then the example program that comes with the eval board will be a great reference.

Once the External Memory Controller is configured properly, the microcontroller should be able to read and write to the external SRAM without any additional driver code. The microcontroller should also be able to read from the external flash without any special driver code. However, writing to the external flash will require some special driver code that you will have to incorporate in your program. Refer to the flash part's datasheet for the erase and program algorithms that are required to reprogram the flash. Once again, an eval board example would be a good reference.

(If you don't need to reprogram the external flash at run time then you may not need the flash driver code. For example, you may be able to get by with reprogramming the flash via JTAG with a special flash programming application on your PC.)

I'm not familiar with the internal bootloader provided with this microcontroller. I suspect it reads code from the UART and copies it into internal SRAM and then executes it. I doubt that this bootloader will support your external memories automatically. But you may be able to get the source code for the internal bootloader and then customize it by adding support for your external memories.

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for your help. I asked this question almost 3 years ago when I was a little (lot) green. \$\endgroup\$
    – morcillo
    Commented Dec 30, 2014 at 23:47
1
\$\begingroup\$

I'll try to field your questions in the order that makes the most sense to me:

Would I have to write a bootloader and record it manually on theexternal flash or can I just use the internal bootloader, and somehow map it to the external devices?

You will have to write your own bootloader for this part. The bootloader will have to read the program stored on the flash (likely using SPI) and load it to your external RAM. A good description is given in this application note: AN10835 - LPC2000 secondary bootloader for code update using IAP

Is it only necessary to connect it via hardware and put LOW or HIGH on some pins on boot for the microcontroller to recognize those external resources as its own, or will I also have to do something else?

In order to use external SDRAM you will have to properly configure and initialize the external memory controller on the device. This includes configuring the pins on that part for their alternate functions. For this, I'd recommend studying the chapters on pin configuration and the external memory controller in the LPC2294 user manual carefully. Then I would suggest get an eval board that comes with demo code for setting up the external memory controller and initialization code for the SDRAM on the eval board. A quick google search turned this eval board up:LPC-L2294-1MB(www.olimex.com/Products/ARM/NXP/LPC-L2294-1MB/), which also has some bootloader code. You can probably find others.

Once you feel you understand what the EMC and SDRAM initialization code are doing, you can think about selecting select a different SDRAM for your application. You should be able to read through the data-sheet and figure out what modifications you need to make to the initialization code from that point. Unfortunately, setting up the EMC for external SDRAM for the first time is non-trivial compared to some other peripheral setups. I would suggest you make use of the resources and forums at LPCWare (www.lpcware.com) to aid in your efforts.

What I want to do is connect those ICs to the microcontroller in order to expand its Program memory and data memory automatically (which means that I don't want to have to create a method to write on the flash or SDRAM, I want the microcontroller to be able to tell that it has those resources, and use them as if they were the microcontroller's on chip memories).

As I mentioned, for the FLASH, you're probably stuck implementing a custom bootloader as described in the AppNote. In the case of SDRAM, there will be a memory range extending from some base address defined for external SDRAM. Effectively, the microcontroller knows to use the external memory controller when it executes instructions that access those addresses, so it's fairly seamless during application development once it's set up. To get a better understanding of how the external memory controller works with dynamic memory I strongly suggest you also read the technical documentation provided by ARM: ARM PrimeCell™ MultiPort Memory Controller (PL176) Technical Reference Manual

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.