Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

C programming for microcontrollers

Joined
Jan 10, 2016
Messages
5
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,455
Hi,
When it comes to writing firmware in C for microcontrollers like ARM, we consider memory consumption a prominent factor, so considering that I want to know that if I use pointers as members in a structure and before making a variable of that structure I allocate memory to the pointer (dynamic allocation), is it okay or should I use array as structure member (static memory assign) and then use it.

Apericiate the help.
 
Hi,

I´d say it dpends on your application.
ARM based microcontrollers usually have a lot of RAM (compared to AVRs and PICs).

So the first thing I´d do is to write down how much memory you expect to use .. and for what.

The amount of used memeory doesn´t much depend whether you use pointers or not. Pointers are for accessability and thus influence speed.

Klaus
 
Depending on compiler pointers can both increase MIPS and decrease code
size due to the elimination of copying by the compiler. Interrupt routines
especially benefit, eg. eliminating large stack push that results from lack of
pointer usage, again depending on what user is doing in code with variables
and the ISR.

One example where I was desperate, in a 32K part, to get back 2K, I focused
on using pointers and got back almost 10K. Thats an extreme example, maybe
tied to my continuing lack of C expertise, but it worked out great. I then promptly
used that 10K and wanted more....

A discussion here https://www.codeproject.com/Questions/5291150/Pointers-in-Cplusplus-What-kind-of-memory-savings



Regards, Dana.
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top