Pages: [1]   Go Down
Author Topic: Duemilanove with Mega328 will not run sketches over 14K  (Read 1210 times)
0 Members and 1 Guest are viewing this topic.
Michigan
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello All,

First time on the forum with a strange issue I did not find in the troubleshooting guide, however there was something that may be a clue. I have been running my home made heating control system for 2 years with the  Duemilanove, I added two more sensors and updated the sketch to include them. This pushed the code over 14K. This causes it to get stuck or repeatedly restart until powered off. I saw mention of this with an older board and 2K boot loader + 14K code = maximum of 16K but I have a 328 ??? The symptoms are identical and repeatable so I am asking for some wisdom from the forum.

I checked the chip to be sure it is a 328 and it is. I do have the right settings in the IDE ( Using the 021 IDE at present ) I have been able to strip some code out and get the project to run at 13820K but my question is why ? The board says is has 30 ~ K every time I compile, I have no reason to believe I have any hardware/software/sketch/communications problems since it has been running and I make tweaks and reload all the time with the current setup. ( Ubuntu 11.04 ).

Some backdrop, The  Duemilanove  with 6 dallas one -wire temperature sensors ( I was trying to add 4 more ) and two relays to control water pumps. The sketch reads the sensors every 60 seconds and writes the values to the serial/USB where the are collected and stored in mysql , I have a website that is built on top to show me the current state, etc etc.
This has been working excellent for 2 years, only the added sensors sent me into a fun day of debugging.

Is it possible to have only 16K on the Duemilanove ? It that separate chip(s) ? Is it possible to have a bootloader that does not work with 32 K ? Has anyone heard of something like this ? And a good way to fix it of course. I suspect Ihave something from the transition to the 328 that has been lying in wait for my sketches to get over 14K.

Any help would be appreciated. My grand plans for expansion are stalled!



Logged

arduino, dallas one wire, home boiler control.

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17303
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Could it be that you are running out of SRAM rather then FLASH memory with the added sensors? There are posting around on how one can check to see if SRAM is running low, not simple but possible. The easiest way to free up some SRAM space is to move constant string data into flash memory.


Lefty
Logged

Michigan
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'll look into this. Thx. I was not aware of the difference and their usage. I'll do some homework on the two.

-- Checked into this, It does not look like this is the issue. I have done a rough calc and cannot even get close to 1K in variables let alone 2K.

All the strings in the sketch are literal and should act as constants and wind up in the code/flash segment unless this compiler behaves different than std C style. Even with them I would not be close to 2K.

« Last Edit: September 19, 2011, 09:11:44 am by mwk1000 » Logged

arduino, dallas one wire, home boiler control.

Maryland, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Strings/constants are stored in SRAM fyi.  They are copied from Flash to SRAM upon startup/reset and referenced entirely from SRAM afterward.  To keep them in Flash and use them from there, you have to declare them with the PROGMEM keyword and use the prog_* functions to read them into SRAM-bound variables (usually a small char array you copy them into & then print out, etc)

This should get you started: http://www.arduino.cc/playground/Main/PROGMEM
« Last Edit: September 20, 2011, 06:17:05 am by spirilis » Logged

Maryland, USA
Offline Offline
Full Member
***
Karma: 0
Posts: 162
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also a little more info from the AVR-LibC library itself, explaining why this is the way it is: http://www.nongnu.org/avr-libc/user-manual/pgmspace.html
Logged

Pages: [1]   Go Up
Jump to: