How to check ATmega328 or ATmega168

Hi!!

I've just start with Arudino, and I'm delight with this platform. But, I'm facing a very strange problem.

I'm using a Duemilanove with an ATmega328, and suddenly my program got crazy. After a lot of testing (A LOT) I detected than the more size my code has, the more problems in my program. My code has 17KB, and doesn't use much SRAM (all strings are defined as constants in the code). But, as soon as I try with shorter codes (<14KB), then everything worked fine.

This makes me think... ¿Am I using a ATmega168, with 16KB? The chip is clearly identified as "ATmega328" (but with a paper label) and I can't access now to the chip.. but... ¿Is there any code I can test to check which chipset version am I using?

¿Or... is there any other cause for his behaviour?

Thanks for your time

Alberto.

doesn't use much SRAM (all strings are defined as constants in the code)

It's not just constants variables and arrays take up space as well as the depth of procedures. That is a procedure calling another procedure and so on.

Is there any code I can test to check which chipset version am I using?

It is built into the environment. If you select the wrong board / processor, you will get an error when you try and uplaod the code.

Thanks for the quick answer.

It's not just constants variables and arrays take up space as well as the depth of procedures. That is a procedure calling another procedure and so on.

Yes, I know, but i doesn't have any recursive procedure or something similar. I don't use pointers or string operators, so I think it can't be related to a pointer issue. But as I'm using 3th party libs I can't be 100% sure (NewSoftSerial and TinyGPS from arduiniana.org so I think it's are a sure source)

Is there any Arduino simulator or similar where I could test the SRAM use?

(all strings are defined as constants in the code)

Defining a string as "constant" does not prevent it from occupying RAM; you have to go beyond that to putting the strings in PROGMEM and using special code to fetch/store them.

Hi, its not that I don't believe you ...

(all strings are defined as constants in the code)

but I've seen this a couple of times ... You have already read this here?
http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_rom_array

Eberhard

When I say that all my strings are defined as constants, I mean than all the strings are send to the LCD in this way:

lcd.print("Stuff to string");

There is no char * or string declaration in the code.

Anyway, thanks for all your post, I'll try to make more tests to fine understand the problem.

lcd.print("Stuff to string");

This will end up putting the string in RAM...

Thanks for all your help. I use the command avr-size with the el file and I got:

text data bss dec hex
14688 1642 378 16708

the SRAM usage (data+bss) is greater than the SRAM limit (2k), so of course you're right.

I'm going to change all may code to use PROGMEM