FreeRTOS on AVR with external RAM

AVR microcontrollers aren’t the best choice to run FreeRTOS scheduler due to low on-chip RAM. Atmega128 has only 4K of RAM, so this limits the FreeRTOS functionality to very basic. Anyway, this problem can be solved by adding extra RAM which may be connected to an external memory interface. We have already built an external memory block of 8K previously so now we can test it with FreeRTOS applications. Lets continue with our previous code which runs several simple tasks (button state reading, LCD output and LED flash), and  we can add more to it. We are going to set up an external RAM for storing heaps. This will allow to store large data buffers without worrying too much about heap and stack overlaps.

Continue reading

Adding external memory to Atmega128

Atmega128 is equipped with internal 4Kbytes of SRAM memory. Is it enough? Well, it depends on what project it’s going to hold. If your project must deal with loads of data or run larger RTOS code, you will run out of RAM pretty soon. Atmega128 microcontroller has an external memory interface built in, which allows to expand RAM up to 64 Kbytes. With that, you could do much more. To test things out, I used Piconomic Atmega128 development board, which has an XMEM interface header brought out. All we need is to make XMEM expansion board with some SRAM memory. I’ve chosen standard 8Kx8 (8Kbytes) memory chip from Alliance Memory Inc. I could use 64Kx8, but this is what I had at the moment. To drive memory chip I’ve used 74HC573 non-inverting latch. As you may know, the latch is used for pins that share the same pins for address and data buses. To access SRAM contents, we need to select a 16-bit address that points to an 8-bit data cell in the chip. As we are using 8Kx8 memory chip, we are going to use only 13Address lines. The microcontroller has dedicated pins for that:

Continue reading