What can cause hidden growth in data section?

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

I'm slowly building an LCD and keypad based controller, currently using an ATMEGA163 since I had one on hand. I've noticed that as I'm adding more and more code to the program, my data section seems to keep growing, even though I'm not adding initialized global variables. In fact, as a test, I eliminated all initialized global variables, and the .sym output shows I still have 644 bytes of space assigned to the data section! See sym output below - what could be causing the data section to range from 0x60 to 0x2e4? I can't afford to loose all that space! I'm asking a generic question - I'll consider posting the source code only if there isn't a generic answer to this.

00800060 D __data_start
008002e4 B __bss_start
008002e4 D __data_end
008002e4 D _edata
008002e4 b row_addr
008002e8 b up_char
008002f0 b bar_char
008002f8 b dn_char
00800300 b menu
00800400 b menu_start
00800401 b menu_size
00800402 b UART_RxBuf
0080040a b UART_RxHead
0080040b b UART_RxTail
0080040c b keypad_2nd
0080040d b portid
0080040e b inc_start
0080040f b inc_finish
00800410 b inc_dur
00800411 b pulse_dur
00800412 b delay_status
00800413 B command
00800417 B __bss_end
00800417 ? _end

Environment: Win 7 64-bit, Atmel Studio 7, Atmel AVRISPMKII

AVR Projects: Time display, X10 automation, matrix LEDs, Caller ID, Halloween props, Pyrotechnic (all hobby)

AVR devices: mostly ATMEGA328, ATMEGA2560, ATMEGA32, ATTINY2313, AT90S2313, AT90S8515

Other hobbies: Electronics, 3D printing, collective-pitch RC helicopters

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

String literals?

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

Yes - By experimenting, I figured it out about the time you were posting your reply. I do a lot of menu initializations like the following:

strcpy(array,"This is a test");

The above code adds 14 bytes (the length of the string literal) to the data section, even though the space won't show up in the symbol listing. Now I know, and I can go back and rethink how I'm doing the menu initializations! Off to re-read the documentation on accessing strings from flash...

Environment: Win 7 64-bit, Atmel Studio 7, Atmel AVRISPMKII

AVR Projects: Time display, X10 automation, matrix LEDs, Caller ID, Halloween props, Pyrotechnic (all hobby)

AVR devices: mostly ATMEGA328, ATMEGA2560, ATMEGA32, ATTINY2313, AT90S2313, AT90S8515

Other hobbies: Electronics, 3D printing, collective-pitch RC helicopters

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

strcpy_P(array, PSTR("This is a tet"));

Jörg Wunsch

Please don't send me PMs, use email if you want to approach me personally.

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

Further information:
http://www.nongnu.org/avr-libc/user-manual/index.html
Related Pages/Frequently Asked Questions (14)