Dynamic Allocation of 2 dimensional array

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

Hello,

I am doing a Led Matrix project and I want to dynamically allocate two dimensional array based on the number of digit I use.
I found a code on the internet that uses Malloc function to make this, but It did not work. I know that the issue in the code because it works fine when i allocate the array fixed.
Can u help?

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

Have you set your heap to be large enough? This is done in the linker file.

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

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

So let's see, you have this huge pile of RAM that you want to dynamically take a piece of, then return to the "OS" when you're done ? Sounds interesting. How much RAM do you have, and how much do you need to dynamically allocate ? With all of these multiple threads running, how can you be sure that you have enough ? < Can you see my tongue in cheek ? >

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

Quote:
I am doing a Led Matrix project and I want to dynamically allocate two dimensional array based on the number of digit I use.
Are you really going to change the number of digits on the display at run time? How will the AVR know how many digits the display has?
Quote:
I found a code on the internet that uses Malloc function to make this, but It did not work.
In what way did it "not work"? Did it not compile? Did it not create an array of the proper size? Perhaps if you showed us the code (and which AVR you are using) it might help us determine the cause of the problem.

Regards,
Steve A.

The Board helps those that help themselves.

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

It works fine when expanding the heap size. Thanks of the help