Pages: [1]   Go Down
Author Topic: Bug with ATMEGA168 memory  (Read 615 times)
0 Members and 1 Guest are viewing this topic.
Curitiba PR, Brazil
Offline Offline
Full Member
***
Karma: 0
Posts: 234
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have a Boarduino with AMTEGA168 chip, and when I upload a program that is greater than half of the flash memory (near of 8000 bytes...), the microcontroller bugs, and sometimes it self-resets. my program have a lot of "Serial.print" and I see only meaningless characters on serial monitor.
Someone have any idea of thats wrong? Apparently Arduino are crashes RAM...
Logged

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

Quote
greater than half of the flash memory (near of 8000 bytes...),

Remember while a 168 may have 16k of flash it has only 1k of SRAM that holds all your variables, arrays, strings, stack space, etc. So it is quite possible that your sketch is going buggy because it's running out of SRAM. Possibly if you post your sketch some of the software gurus around can see what is what.

Lefty
Logged

Curitiba PR, Brazil
Offline Offline
Full Member
***
Karma: 0
Posts: 234
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Really, my sketch have about 1500 lines, and is probably that it's running out of SRAM...

Maybe if I use the function "PROGMEM" to allocate my variables in flash memory, the program runs ok. Will look this up a little more, thanks.
Logged

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

That can certainly help. Also a cheap upgrade is to swap in a 328 chip that will double both flash and SRAM size.

Lefty
Logged

Curitiba PR, Brazil
Offline Offline
Full Member
***
Karma: 0
Posts: 234
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Really, I use the library "pgmspace" to alocate the strings in Flash memory with the function "PROGMEM" and it finish with my problem  smiley
The syntax of the sketch was more confuse, but now I don't have problem with RAM.
Thanks.
Logged

Pages: [1]   Go Up
Jump to: