I have chosen a specific microcontroller (MCU) for a project, based on price, package size, and speed. It's the NXP LPC1768FBD100, a 100 MHz ARM-based MCU with 512 KB program memory and 64 KB SRAM.

My code will certainly fit in that 512 KB but some data must be read from another source in order for the code to run properly.

That data certainly won't fit in that memory. It's raw weights and coefficients needed for some numerical and statistical analysis by the MCU and sums up to a few hundred megabytes.

These large-ish datasets are seldom updated/changed, though not by the MCU, so they're better not be written into the MCU's program memory over and over again, even if they'd fit.

What kind of memory do I need to use in this project beside the MCU and how do I set it up?

I know the theoretical differences and definitions of SRAM, DRAM, NVMe Flash etc.

I know the large data should be stored in a non-volatile memory, but the memory sizes on the MCU indicates that it can't load the whole data.

Does this mean I need non-volatile memory plus some volatile memory (SRAM, DRAM, SDRAM) for this project?

  • 1
    \$\begingroup\$ Do you need all this data in the same time? Or you need only small chunks of it at each point of time? And how fast you need to swap these chunks? If not that fast, you can store them in some off-chip flash and load on demand. \$\endgroup\$
    – Eugene Sh.
    Aug 4, 2022 at 15:10
  • \$\begingroup\$ Ideally loading all. But not possible due to mC memory limitation. Speed compromises even down to %50 are ok. \$\endgroup\$ Aug 4, 2022 at 15:14
  • \$\begingroup\$ What do you need to do with the hundreds of megabytes? I guess that is some big calculation that uses all of it (not just small parts). How often do you need to do that calculation? \$\endgroup\$ Aug 4, 2022 at 16:03
  • \$\begingroup\$ Usually, for such large datasets, an SD Card is the solution. FAT can be implemented even with 128KB of program memory. \$\endgroup\$
    – Lior Bilia
    Aug 4, 2022 at 16:48
  • 1
    \$\begingroup\$ @Rodo, an FPGA would be a poor and unsuitable choice here, though. It'd cost significantly more and then all the processing and datapath logic needs designing and a lot of testing. The MCU has all that already done, so zero cost and time there, can get on with the software. \$\endgroup\$
    – TonyM
    Aug 4, 2022 at 18:05

1 Answer 1


What kind of memory do I need to use in this project beside the MCU and how do I set it up?

You need external non-volatile memory of a type that the MCU can interface to for reading. Some method of updating the data will also be required. Your MCU does not have an external memory interface so it will have to address the external memory as a serial block device or data stream, or create an external 'bit-banged' bus with GPIO.

Next question is what type of external memory might be suitable. For 'hundreds of Megabytes' you are looking at NAND Flash, either as a bare chip or on some some kind of card (Micro SD Card, USB stick etc.). You can also get NAND Flash chips with SPI built in or on a module (eg. Adafruit XTSD 512 MB).

Your MCU's maximum SPI data transfer rate is 33 Mb/s or ~4 MB/s. This is very slow compared to the CPU's 100 MHz clock. However SPI data can be read into a buffer via DMA at the same time as the CPU is doing other stuff, so depending on how much 'numerical and statistical analysis' is required it may not have to wait often.

Alternatively you could use an SD Card in SPI mode, or a USB stick via the USB OTG interface. These solutions are less compact and robust, but have the convenience of being able to easily update the data with a PC (especially if the data if data is supplied as a file), and can provide much greater storage capacity.

If SPI or USB is too slow then you might consider compressing the data for storage, and decompressing it 'on the fly' while reading. A compression scheme could be chosen that is optimized for fast decompression, which could be faster than reading uncompressed data as well as reducing the amount of memory required.

The fastest reading speed would be obtained using GPIO with a parallel NAND Flash chip and custom controller (CPLD?). However this will take up a lot of GPIO pins, and getting the interface working properly could be tricky. The CPU may also need to write to the Flash for updating data, since it may not be practicable to do it externally.

  • \$\begingroup\$ Thanks. I have a few NAND chips from samsung (K9F2G08U0C). Will they do? \$\endgroup\$ Aug 5, 2022 at 5:36
  • \$\begingroup\$ @Elementronics as usual it depends on the requirements. Since your MCU doesn't have an external memory interface you will be controlling the memory chip "manually". Have a look at what you have to do, and consider whether you can do it as fast as you want to. \$\endgroup\$ Aug 5, 2022 at 14:35
  • 1
    \$\begingroup\$ They look to be suitable, bearing in mind that they are bare NAND Flash chips so you will have to either bit-bang them directly or use an external controller. Here's an example of bit-banging using the GPIO on an FT2232H:- spritesmods.com/?art=ftdinand&page=2 \$\endgroup\$ Aug 5, 2022 at 23:32

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.