ATMega328 Memory Limitations

Go To Last Post
20 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many of the projects I've made on the ATMega328p depend on 3rd party libraries - and these are often large. A TFT-touch library and SD Library alone could nearly fill the 32k flash. Wonder if Atmel might increase the memory - say double flash/sram, without any other alterations?  The physical cost would be neglible, would it not? Apart from the retooling of course.

edit- Personally I would pay double, or more for such a chip.

Last Edited: Tue. Apr 10, 2018 - 09:25 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many of the projects I've made on the ATMega328p depend on 3rd party libraries

Is your library card current & not accruing fines from Atmel?   You can always hope, but they probably want to push their 32 bitters.  Some AVR  chips have a mem expansion port.  If you don't need fast access some flash items could be places in serial memory.

Their are plenty of other chips with greater flash area, so might be worth just to try one!

 

Apart from the retooling of course.

20% off at Harbor Freight 

When in the dark remember-the future looks brighter than ever.   I look forward to being able to predict the future!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

iBeta666 wrote:

... say double flash/sram, without any other alterations? ...

 

There are 72 AVR chips with double the flash.

There are 43 AVR chips with double the SRAM

There are 34 chips with both double flash and double SRAM and plenty of those will run 328 code with only a quick recompile.

 

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

TFT libraries often have the configuration information for many TFT controllers incorporated into the library source code.  You are likely to save space in flash by removing all the code in the TFT library that is not specific to your controller type.   Constant strings can be moved from flash to EEPROM. 

Try the Adafruit libraries for SD cards and TFT screens.   

I assume that anyone using a mega328P is using an Arduino platform and Arduino C++.  In this case, it is easy to switch to a mega2560.  The same code runs a little slower on the mega2560, because extra cycles are used to access memory above 64K.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 2

I use the ElmChan SD card library on an M328 and it uses less than half of the flash when properly configured. Of course, if you want all of the bells and whistles, it will take more.

 

Jim

Jim Wagner Oregon Research Electronics, Consulting Div. Tangent, OR, USA http://www.orelectronics.net

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ka7ehk wrote:
when properly configured
+1

 

Which flash library are you talking about? If it is FatFs are you just using ffconf.h "as is" or have you studied the implications of enabling/disabling each option? Just picking one at random I think the supplied file has f_mkfs() enabled by default - without building the code with/without this I can't tell you exactly how much flash this "costs" but I imagine this one alone could be 1 or 2K. So you have to ask yourself - do the users of my device really need the ability to format SD/MMC cards in it? Or can they just rely on the fact that SD/MMC always come preformatted with FAT? Or if they really needed to have the function couldn't they just format the card in the slot of their PC? You need to look at all the other options in ffconf.h too on a similar basis. (rename? for example). Another large flash eater in FatFs is the code page support - as supplied it is set to Japanese - do you really want to created filenames containing Japanese characters? In fact do you even want to create Long File Names?

 

If you just pull and build FatFs I think it comes out at something like 22K these days. You can easily get that down around the 10K mark or less.

 

If it's not FatFs you need to look into whether the library you do use is similarly configurable.

 

The same may also be true for TFT. It would only need a few 256 character font definitions to eat a lot of RAM. Again you may find it could be easily changed to just cut those down to an "ASCII" range of characters and you may find whole fonts that could be removed.

 

Anyway as others have suggested what is the key design feature of the 328 that makes you use that one? Is it the fact that it is a 28pin DIP? It's true that it might be tricky to find a 28pin DIP with more than 32K but if you are flexible on the package size then obviously there are other mega chips up to 256K and even Xmega up to 384K.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

iBeta666 wrote:
The physical cost would be neglible, would it not?

Not sure what you mean by that?

 

The physical cost of the chip material is negligible in any chip.

 

Apart from the retooling of course.

and design, and testing, and ...

 

Which is, of course, where all the cost comes from.

 

SRAM is (relatively) expensive. This is why small, cheap micros don't have much of it, and big computers don't use it for their large memory areas.

 

With 8-bit processors, there is also the issue of addressing it ...

 

But, nowadays, there is no shortage of small, cheap microcontrollers with hundreds of K of SRAM - so if memory is your key requirement, why stick with a chip that lacks it?

 

 

 

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I think that the OP is wishing for a ATmega648P to extend the MEGAxx8 family of TQFP-32 chips.

 

Yes,  it would be nice to have an Arduino Uno with more memory.      Microchip would make a 648P if they thought it profitable.

Arduino users would only gain if Chinese produce cheap clones.

 

But you can do quite a lot with 32kB Flash and 2kB SRAM.

A Uno can store multiple images and fonts via a SD card.

 

Alternatives are Arduino Zero with SAMD21 chip.

Or other makes of chip on a board with Uno-style Arduino headers.   e.g. STM32 Nucleo, Expressif ESP32, ...

 

Arduino Mega2560 and Due have lots more GPIO pins and bigger headers.  And have cheap clones.

 

David.

Last Edited: Wed. Apr 11, 2018 - 09:57 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Or other makes of chip on a board with Uno-style Arduino headers.   e.g. STM32 Nucleo, Expressif ESP32, ...

I think the "Uno-style Arduino headers" are pretty much de rigueur these days - just to keep @Pauldvh happy  wink

 

And, of course, you can now do Arduino on the STM32 itself.

 

EDIT

 

Meant to add:

 

Due have lots more GPIO pins and bigger headers

and 96K RAM

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Apr 11, 2018 - 10:24 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:

I think that the OP is wishing for a ATmega648P to extend the MEGAxx8 family of TQFP-32 chips.

 

They make one, it's called the mega1284P! Available in DIP and small pin-count TQFP. Sure, it's in a 44-pin package but that's only 3mm a side longer and still a 0.8mm pitch.

#1 This forum helps those that help themselves

#2 All grounds are not created equal

#3 How have you proved that your chip is running at xxMHz?

#4 "If you think you need floating point to solve the problem then you don't understand the problem. If you really do need floating point then you have a problem you do not understand." - Heater's ex-boss

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

First:

The silicon area of a chip is an important factor of chip cost, because a lot of the costs scale with it.

Flash needs silicon area, lots of flash is lots of silicon area.

 

When you want to control TFT lcd's you're running pretty much out of steam with the AVR controllers.

They are simply never designed for such applications.

"newer" uC designs with (probably) denser process technology can have 10x or 100x the complexity of an AVR at comparable prices.

 

awneil wrote:
And, of course, you can now do Arduino on the STM32 itself.
I'm not sure if OP is talking "arduino" here. If OP really wants to use the horrible arduino pinout, there is an "arduino" with an ATSAM3 on it. Plenty of resources for a small TFT.

https://www.aliexpress.com/wholesale?SearchText=arduino+due

 

If you want to go "cheap", then the "maple mini" might be an attractive choice.

https://www.aliexpress.com/wholesale?SearchText=maple+mini

 

But to discuss stuff like this, the stm32duino forum is probably more suitable:

http://www.stm32duino.com/

Doing magic with a USD 7 Logic Analyser: https://www.avrfreaks.net/comment/2421756#comment-2421756

Bunch of old projects with AVR's: http://www.hoevendesign.com

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
I'm not sure if OP is talking "arduino" here

maybe not - but everyone else is!

 

 

 there is an "arduino" with an ATSAM3 on it.

That is the Due - already mentioned.

 

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Paulvdh wrote:
The silicon area of a chip is an important factor of chip cost, because a lot of the costs scale with it.

Indeed.

 

But it's not down to the cost of the materials themselves - which is why I was not sure what the OP meant by, "physical cost" ...

 

 

EDIT

 

Flash needs silicon area, lots of flash is lots of silicon area.

Similarly for SRAM.

 

When you look at photos of chips, the memory areas stand out because they are so big.

 

 

 

EDIT 2

 

In fact, I think SRAM takes more space, bit-for-bit, than Flash?

 

https://electronics.stackexchange.com/questions/134496/why-do-microcontrollers-have-so-little-ram

Top Tips:

  1. How to properly post source code - see: https://www.avrfreaks.net/comment... - also how to properly include images/pictures
  2. "Garbage" characters on a serial terminal are (almost?) invariably due to wrong baud rate - see: https://learn.sparkfun.com/tutorials/serial-communication
  3. Wrong baud rate is usually due to not running at the speed you thought; check by blinking a LED to see if you get the speed you expected
  4. Difference between a crystal, and a crystal oscillatorhttps://www.avrfreaks.net/comment...
  5. When your question is resolved, mark the solution: https://www.avrfreaks.net/comment...
  6. Beginner's "Getting Started" tips: https://www.avrfreaks.net/comment...
Last Edited: Wed. Apr 11, 2018 - 11:11 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The Chinese chose to clone :  Uno, Pro-Mini, Nano,  Mega2560,  Due.

 

There have been several other Arduino designs that remain un-cloned.

And several non-Arduino designs that have never taken off.  e.g. with mega1284P or Xmega.

 

The Chinese choose carefully.   And make significant improvements for design and cost.

The Arduino team produce good hardware and software designs.

Without the Chinese contribution,   Arduino would not be the success that it is today.

 

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many thanks for the suggestions about this.   

I've not got smd soldering capability, so a DIP package is needed. One chip that would do (thanks Brian) is the ATmega1284P, but it has different pins and will not help with projects 

already built.
Another problem is debugging, the 328p uses debug wire, and the inexpensiveness of the dragon debugger was a big factor in using the chip. But given I can get 

hold of a debugger for the 1284p, then it should be fine.

awneil wrote:

Paulvdh wrote:
The silicon area of a chip is an important factor of chip cost, because a lot of the costs scale with it.

Indeed.

 

But it's not down to the cost of the materials themselves - which is why I was not sure what the OP meant by, "physical cost" ...

 

 

EDIT

 

Flash needs silicon area, lots of flash is lots of silicon area.

Similarly for SRAM.

 

When you look at photos of chips, the memory areas stand out because they are so big.

 

 

 

EDIT 2

 

In fact, I think SRAM takes more space, bit-for-bit, than Flash?

 

https://electronics.stackexchange.com/questions/134496/why-do-microcontrollers-have-so-little-ram

I meant the physical cost of the flash/SRAM is somewhat cheaper compared to a decade or so ago, I would've thought.

But surely the silicon area of say 64k flash/4kSRam would not a limiting factor on the 328p?

awneil wrote:

Paulvdh wrote:
I'm not sure if OP is talking "arduino" here

maybe not - but everyone else is!

Ha, now I'll talk about the Arduino Uno. It's been really useful for prototyping/debugging the 328p, but it seems arduino do not support the 1284P, though maybe it will in the future. Otherwise its back to the breadboard.

I still think 32k is not enough, given the size of current libraries - but certainly Atmel do not agree, they have released the 328PB which has more hardware capabilities, but the same memory.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

iBeta666 wrote:
Another problem is debugging, the 328p uses debug wire, and the inexpensiveness of the dragon debugger was a big factor in using the chip. But given I can get hold of a debugger for the 1284p, then it should be fine.
What are you talking about? The Dragon does JTAG as well as debugWire - 1284 uses JTAG. In fact it is a "better" debugging system as there is not all the fannying about with the DWEN fuse.
iBeta666 wrote:
But surely the silicon area of say 64k flash/4kSRam would not a limiting factor on the 328p?
Most of the area of a 328 will be the flash, EEPROM and RAm so, yes, if you double those things you probably double the silicon area and for chip manufacturers (especially when you reach industrial quantities) the chip cost IS very much about the silicon area.
iBeta666 wrote:
but it seems arduino do not support the 1284P
There's almost certainly a 3rd party "core" to support 1284

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

iBeta666 wrote:
I've not got smd soldering capability, so a DIP package is needed.

 

SMD is very easy to learn and the cost of the equipment (see below) is in reach of anyone wanting to learn.  Spend 15 min with one of these to lean to use hot air and it will open another world to you.

https://www.ebay.com/itm/862D-2i...

 

Jim

 

 

Click Link: Get Free Stock: Retire early! PM for strategy

share.robinhood.com/jamesc3274
get $5 free gold/silver https://www.onegold.com/join/713...

 

 

 

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Now, this is "AVRfreaks", after all.  But there are a number of threads discussing/exploring the 20-year-old AVR architecture.

 

If you are starting with a clean sheet of paper (i.e. a new app) and you like SRAM and flash in your microcontrollers in a goodly amount, then how much of those do you get in CortexM models for a buck or two.

 

A '328 is already expensive in comparison.  I cannot see where your '648 proposal will have many legs.  Did you ask Microchip?  What did they say?

 

iBeta666 wrote:
Wonder if Atmel might increase the memory
...you do realize that there is no longer an Atmel?

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 1

You can use your Dragon to debug the ATmega1284 via JTAG.
AVRs are nice simple devices. And many are available in DIP.
.
Seriously. If you have a project, write down your pin budget. Then see what devices are suitable.
Many chips are available on evaluation kits with onboard debugger. Excellent for prototypes and experiments.
.
David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

david.prentice wrote:
Yes,  it would be nice to have an Arduino Uno with more memory.
That's on the way with three times the SRAM and some more flash.

mega4808 has 32 pins but it's a future product.

 

https://www.avrfreaks.net/forum/megaavr-0-series#comment-2407411

https://www.microchip.com/wwwproducts/en/ATMEGA4808

https://www.microchip.com/wwwproducts/en/ATmega328PB

http://svn.savannah.gnu.org/viewvc/avrdude/trunk/avrdude/NEWS?revision=1425&view=markup

 

"Dare to be naïve." - Buckminster Fuller