I've written a few 8bit embedded systems and the codebase I inherited and have expanded is basically 80% global variables (extern volatile), and than non-global control flags and logic variables as needed.
The end result, is that you end up with a lot void() functions to modify the global variables.
The systems run fine and the software quite readable and easy to work on, but I always have that design nag in the back of my head that I should be refactoring everything and pointer'ize the next design.
I don't have any religiosity about the memory usage aspect, the static memory is there to use as much as the heap is. It's more a question of as systems get larger, I suspect maybe the globals start to be more of a hinderance than you think? I've never gotten there in program size.
Do many of you experienced embedded software programmers use pointers extensively in your 8bits systems?
I can think of three possible use cases for using pointers in C51: linked lists (which we don't use) in this system, structs in place of independent variables and then functions with pointers to modify the strucs, maybe a double pointer if you absolutely need to modify a pointer but I can't fathom a situation in building a consumer product with an 8051 (maybe building an OS...).
I get that the functions can get re-used if you pointer'ize your code, but in one sense the functions are pretty trivial and one off in the embedded systems I've built. Very application specific stuff.
A couple of you guys who are still around C51 forum, what is your most compelling (or not compelling) use case for pointers in the code you have released?
@Erik -- I know this isn't C51 related. I spent a day getting a STMicro Cortex M0 development board going. I'm going to port my 8051 project to a Cortex M using FreeRTOS (just to learn FreeRTOS).
I got my board going with some sample code from STMicro.
I used the STMicro easy-tool and it builds a project using CMCIS-Core + STMicros HAL.
The STMicro HAL documentation is 1300 pages!! GEEZ.
www.st.com/.../jcr:content/translations/en.DM00122015.pdf
----
I get that the pre-written middleware (RTOS, TCP-IP, etc.) is going to require you to use that HAL.
As a bare-metal guy at heart when you moved over to Cortex M, did you just learn the vendor HAL and go with their codebase?
To me it seems easier to just set registers with hex, coming from the 8051. But seems like more Cortex M developers, may prefer the HAL functions.
Nope. Like you, I'd describe myself as a bare-metal guy. I prefer to get a full understanding of what's happening and go with the setting up of registers myself.
One point I would add. Erik said:
for a small job you can have the whole '51 project running before you get the cortex BSP done.
That was exactly how 1 felt when I first moved to the ARM. What I've found is that I spent a relatively large amount of time on the first ARM project but subsequent ones have tended to use the same basic startup and structures, so the time to create a new task has been surprisingly efficient.
OK, I may have been lucky in so far as the recent projects have all required a similar amount of processing, so I have used processors from the same family (the LPC800 series).
ps
This forum is seriously sick. I tried to post and got a complaint saying:
Messages cannot contain the spam word "w1fe".
had to look hard to find the cause:
how 1 felt
The i changed to 1 by me to work around it
I suppose the sysop does this to stop people bragging about how good a programmer their w1fe is???
As a bare-metal guy at heart when you moved over to Cortex M, did you just learn the vendor HAL and go with their codebase? I do a mix, I use the "autogenerated" as a base. e.g. on a ST capsense project where the ST code was just not good enough, I removed all ST code but for "get the value" and wrote the rest.
the forum dropped characters above, here it is with splits inserted.
this is complete although one cr is skipped by the forum