Hello,
I am working with Teridian M6531 and I am trying to use memory allocation in my program. I was reading other forums and got the idea that init_mempool function should be used while using malloc. I did use that funtion too. But I am still not able to use malloc. It gives error when I use init_mempool function and it also gives error when I use malloc without init_mempool.
If anybody found such problem and got some solution, please let me know
Regards, Shrenik Mehta
But did you first read the manuals for the compiler that you are using?
"It gives error"
What error?
Note that dynamic allocation is usually best avoided in (small) embedded systems - so it would be helpful if you would explain why you particularly feel the need of it?
I apologize for the incomplete post. Its a 80515 MPU. I almost solve the errors i used to get (would have mentioned it if i was still getting those). I am trying to use malloc() as I have big data structures within my program. When used as a local variable, those structure utilizes some part of my RAM. So I want to dynamically allocate memory for those structures. My program is working fine and I don't want to change it completely. Otherwise I would have broke those structures in smaller once.
Would welcome any suggestions to make my program more efficient.
Shrenik
Yes, of course they do - and if you allocate them dynamically they will use even more of your RAM! (dynamic allocation adds an overhead).
"I would have broke those structures in smaller once."
Eh??
One 100-byte structure occupies exactly the same amount of RAM as ten 10-byte structures (C51 adds no padding).
Dynamic allocation will certainly not make it any more efficient on an 8051!!
View all questions in Keil forum