Problems with array

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

Hi,

I'm using at90can128 and I have a buffer to store my datas.

The problem is: When I'm using a array > 500 it shows most of datas equal "zero".
[both ways compile]
It works when array < 400. my code:

char array[400][8] // it works
char array[500][8] //it doesn't work

how can I fix this problem?

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

What do you get when you compile?

Data:       xxxx bytes (xx.x% Full) 
(.data + .bss + .noinit)

<70%? typicalle safe
>80%? critical
>90%? extreme critical

/Martin.

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

I'm getting datas from a CAN NETWAORK. I just need creat a array with 1000 positions, but when I do that, all datas comes equal to "zero".

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

Just use some common sense. What data is going into the array ? Will every element be full of 8 chars ? Or will some elements be empty ?

Your CAN128 has got 8kB of SRAM (I think).
You have little chance of ever allocating 8000 bytes to the 1000 element array and still running most applications on the other 192 bytes.

If your array is 'sparse', you can use different storage methods. e.g. a linked list.
If you really need 8000 bytes, you will have to put some data in your 4kB EEPROM or possibly add an external SPI or I2C chip for RAM.
The CAN128 might permit an external memory bus. I always think they are a 'waste' but hey-ho you know your application. Can you spare all those pins ?

David.

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

Quote:
char array[400][8] // it works
char array[500][8] //it doesn't work

The chip has 4kB of SRAM.

No RSTDISBL, no fun!

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

Quote:
Your CAN128 has got 8kB of SRAM (I think).

Guess again...
AT90CAN32/64/128 datasheet wrote:
– 2K/4K/4K Bytes Internal SRAM (AT90CAN32/64/128)

EDIT: Brutte beat me.

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

Well, with 4kB of SRAM, you have little choice. You need to use some external memory.

This would be the first consideration in your original design.

If your data is not changed very frequently, you can also use your onboard EEPROM or FLASH.

David.

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

Since you only need 1K of RAM, why are you coding for so much more, with either code version ? Are you sure it has to be 2D array and that you can't just use :

char   some_array[1000];

1) Studio 4.18 build 716 (SP3)
2) WinAvr 20100110
3) PN, all on Doze XP... For Now
A) Avr Dragon ver. 1
B) Avr MKII ISP, 2009 model
C) MKII JTAGICE ver. 1

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

atflaryon wrote:

char array[400][8] // it works
char array[500][8] //it doesn't work


AT90CAN has 4kB of Ram= 4096 bytes, your code that works is [400][8]= 3200 bytes of ram yo get left 896 bytes for your program, I thinks that´s good enought, but when you use [500][8]= 4000 bytes of ram, leaving you only 96 bytes of ram for your progam that´s very little. Like they tell you use some external RAM they are some whith SPI interface I think from ramtrom or microchip, or like they tell you use a 1-D array with 1000 positions not a 2-D array wih 3200 or 4000 positions depending on the case

1-D array with 1000 position:

char 1darray[1000];

Entra a www.mecatronicamexicana.blogspot... y ve lo que los estudiantes Mexicanos de Mecatronica hacen y conoce un poco más acerca de Mecatronica

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

I found the problem. My ATmel Studio was accepting tha my AT90CAN had 64k of SRAM. But this value is for adding a extra memory, the real value is 4k of SRAM. THANKS EVERYBODY.