Arrays of data

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

Hello,

I'm trying to use large arrays of data on a Atmega8515 but it doesn't seem to work. Those arrys are passed to a function. Is there a better way to do it.

I'm using the avr-gcc compiler.

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

Depending on where the arrays are declared they could be global and would be seen by the function (ie: if they are declared outside main(). If you have them declared within
main(), then you should be able to just pass a pointer.

Dave

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

What's not working?

Could we see a code fragment?

/A

If we are not supposed to eat animals, why are they made out of meat?

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

dharper wrote:

...If you have them declared within main(), then ...

... a large array could very well cause stack problems.

Lee

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: 0

Your internal SRAM is 512 bytes. How large is your large array?

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

The problem ios exactly that. The large array is 256 bytes and i think it is messing up the stack.
what can be done to avoid it?

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

dguerre wrote:
The problem ios exactly that. The large array is 256 bytes and i think it is messing up the stack.
what can be done to avoid it?

Either use a bigger device or less data. :wink:

I don't know offhand if the mega8515 allows you to attach external memory, but that's usually another route.

What are you using the data for?

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

Hi there,

I am facing the same problem. Need an Array of 512 variables. To sample a analog signal of 15 ms long. (240 samples)
Letting the ADC sample and store in an Array, and later write it to EEPROM. Note that the whole thing works for Arrays under the 110.

Using a Atmega32 with 2048 bytes SRAM.
Declaring the array as followed:
unsigned char ucArray[512]; in the global variables.
With 110 i'm getting problems. My thought was: 2048 bytes SRAM, a unsigned char is 2 bytes. So I need 1024 Bytes of memory. Half of wat is available.

Any suggestions how I should face this problem?

Thanks a lot,
Daniël Hullie

void

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

A char, unsigned or not, occupies only 1 byte on the Avr.

/A

If we are not supposed to eat animals, why are they made out of meat?

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

You might be right but that is not quite the issue

void

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

Hi,

I would simulate your code on AVR Studio - check that you don't do anything crazy by accident, like accidently pass that array on the stack (and not a pointer) or something to that effect... because you should have lots of room!

Just monitor the memory, see how far it is written up to. You could also check the output of your compiler, it should tell you SRAM useage (not including stack though).

Regards,

-Colin

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

Ok, I use the IAR compiler and the problem is in the memory type, it was on TINY and should be on SMALL for the large array to work.

I've read out the eeprom and this are the values put in an excell thingy.

It's a 1kHz signal AD-converted and stored in the EEPROM.

Attachment(s): 

void