Dynamic Memory Allocation in PSoC3

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

 Hello,

   

 

   

In a recent project I was attempting to dynamically allocate arrays within functions but the results I would get were not consistent or expected. After browsing the forums I found some mention (by the ailurophile forum frequent Bob) that in order to correctly allocate memory using malloc, a call to initmemset must be used. However, I could not find documentation on this function and so I do not know how to use it.

   

 

   

Is Bob correct in saying that malloc will not work without first calling initmemset? And if so, how do I correctly use initmemset?

   

 

   

Thank you,

   

Seamus

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Yes, Bob is correct that there must be an initialization

   

look here www.keil.com/support/man/docs/c51/c51_lib_memory.htm

   

 

   

Bob

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

BTW: 5 cats, 3 dogs and the picture (a bit small) is mostly because of the mouse.

   

 

   

Bob

0 Likes
Anonymous
Not applicable

 Bob,

   

 

   

Thank you very much for that link. While doing embedded development on Atmel microcontrollers, I don't remember having to use a function to initialize space on the heap. Is this a common function that Atmel controllers don't use or is this a specific Keil compiler issue?

   

 

   

Seamus

   

p.s. Now that you mentioned the mouse, your profile picture makes a lot more sense. 

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

The 8051 was developed in 1980. Compared to the rapid change of IT developments this is far more than old. New techniques, even new computer languages and compilers have been created since. "C" was known for just 8 years and did not yet influence the microprocessor architecture. So using a PSoC3 whichs core is an 8051 CPU will always have some more restrictions and oddities than a PSoC 1, 4 or 5 which all have got more modern cores, although the PSoC1 has got a minimalistic version only. (a hint: try to use pointers to functions in PSoC3 and get lost).

   

 

   

I personally can understand why people use a PSoC3 (Oh, a 8051! I know that chip, let's take THAT!), but I would alwways choose a more modern architecture for more modern designs.

   

 

   

Bob

0 Likes