Click here to Skip to main content
15,887,027 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Swimming out past the markers Pin
BillWoodruff22-Jul-23 20:05
professionalBillWoodruff22-Jul-23 20:05 
GeneralRe: Swimming out past the markers Pin
honey the codewitch22-Jul-23 20:07
mvahoney the codewitch22-Jul-23 20:07 
GeneralRe: Swimming out past the markers Pin
Cpichols24-Jul-23 2:05
Cpichols24-Jul-23 2:05 
GeneralRe: Swimming out past the markers Pin
honey the codewitch24-Jul-23 2:31
mvahoney the codewitch24-Jul-23 2:31 
GeneralRe: Swimming out past the markers Pin
Cpichols24-Jul-23 2:54
Cpichols24-Jul-23 2:54 
GeneralRe: Swimming out past the markers Pin
trønderen24-Jul-23 7:25
trønderen24-Jul-23 7:25 
GeneralRe: Swimming out past the markers Pin
sasadler24-Jul-23 7:08
sasadler24-Jul-23 7:08 
GeneralRe: Swimming out past the markers Pin
Member 1488449224-Jul-23 10:25
Member 1488449224-Jul-23 10:25 
Embedded programming is antithetical to pretty much every programming trend of the last 20 years. Note: If you are programming on a board that runs Linux or Android then this discussion is not really aimed at you.

Deeply embedded systems are often built on severely resource constrained hardware. The typical embedded system uses only the memory built into the processor which can be a lot less than you expect. Cortex M0 processers for example come in variants with as little as 32KB FLASH and 2 KB RAM. Note the K vs M.

The primary embedded programming languages is C (not C++ even though your compiler will claim to be C/C++). You will also need assembly code if you do board support packages. If you are not a proficient C coder, then get a good book and teach yourself.

Book recommendations: All of these are older than dirt, but they are classics for a reason and will help you develop the mindset of an effective embedded programmer. Some of these are available as free downloads.

* "Practical C Programming" by Steve Oualline for learning C coding in general.
* "The Art of Embedded Systems" by Jack Gansslle for the general philosophy of embedded programming.
* "Math Toolkit for Real-Time Programming" by Jack Crenshaw for complicated math.
* "Insiders Guide to the Phillips ARM7 based Microcontrollers" by Trevor Martin for using processor resources.

Martin's book on Philips ARM7 is the very best hardware tutorial book I have ever read. Hitex did a great thing for embedded programmers when they released this book as a free download (I think Philips paid for this book). I wish they had done the same thing for Cortex M processors, but life happens and money is not infinite.

https://perswww.kuleuven.be/~u0068190/ARM7/lpc-ARM-book_srn.pdf

Embedded systems can go years between reboots and memory usage management is up to the programmer. Automatic memory allocation (malloc, new, etc.), or anything object oriented can be dangerous. Be wary of any library code that uses these kinds of things. This is one of the reasons why I want the source code for all libraries I use.

Ring buffers are your friend. If properly implemented, buffer overflow exploits just became a thing of the past. You will need to be able to deal with missing data. I use packetized messages with error detection and missing message detection built into the communication protocol (I have been using my own processor to processor packetized protocol that I have used and extended over the last 2 decades).

Every embedded product needs a robust powerup self test function. Run a checksum on your application, perform whatever hardware testing you can and protect your non-volatile memory. Break NVM up into structs that fit within your EEPROM page size. Include a non-zero ID value and checksum in each NVM struct. Add limit tests on multiple choice variables, do anything you can do to detect corrupted NVM data since this is a major risk vector for your code. Alert users as best you can when you detect a problem. Always use the enable pin on EEPROMs (don't just tie them to ground). In some EEPROM devices a single bit change (ESD anyone) can turn a read into a write or erase.

Fight to include an LED the user can see for status display, even if you have an operator display. The happy state is best indicated by a slowly flashing (not a solid on or worse, solid off). You can change the flash rate to indicate different status or mode conditions. Pulsed patterns can be used to indicate specific states or error conditions. And don't use a hardware counter/timer to pulse the LED. Put the LED code in the lowest priority (background) task and make it look at variables in each of the other tasks that indicate if the task is hung up.

Embedded systems often directly control hardware. An electrical engineering background really helps. At a minimum, you need to be able to understand an electronic schematic. If you lack this background then I suggest you take some EE classes. Focus on serial interfaces like I2C and SPI. You will also find yourself using UARTs far more than you ever expected. Martin's Philips ARM7 book is a great resource for best to do this kind of stuff.

You will also sometimes have to meet hard real time requirements which are most easily implemented with an RTOS. If there are any hard real time requirements, then start your designs on the RTOS of your choice, because systems inevitably get more complex over time and porting an existing project to an RTOS is a complete waste of time.

F.Y.I. I am very experience using the Nordic Semi SDK and all I can say, this is not a good resource to learn how to do embedded programming. The SDK was designed to work with a wide variety of ARM processors with a minimum of rewriting and the stuff that actually does the work are extremely well hidden and it is difficult to comprehend by reading the tutorial code in the SDK. The SDK is also extremely inefficient (6 nested subroutine calls to toggle a GPIO bit???). The first project I did using this SDK was reading a high speed ADC over a wireless link (5000 reads per second). It turned out I could read the ADC using a bit-bang implementation of the SPI port 3 times faster than the SDK could using the processor's hardware SPI port. That is pretty pathetic.
GeneralTony Bennett at 96 Pin
megaadam21-Jul-23 4:02
professionalmegaadam21-Jul-23 4:02 
GeneralRe: Tony Bennett at 96 Pin
honey the codewitch22-Jul-23 0:10
mvahoney the codewitch22-Jul-23 0:10 
GeneralAnother Legend gone - Tony Bennett Pin
Matthew Dennis21-Jul-23 4:01
sysadminMatthew Dennis21-Jul-23 4:01 
GeneralRe: Another Legend gone - Tony Bennett Pin
Matthew Dennis21-Jul-23 4:06
sysadminMatthew Dennis21-Jul-23 4:06 
GeneralRe: Another Legend gone - Tony Bennett Pin
Mike Hankey21-Jul-23 4:29
mveMike Hankey21-Jul-23 4:29 
GeneralRe: Another Legend gone - Tony Bennett Pin
jeron121-Jul-23 7:32
jeron121-Jul-23 7:32 
GeneralMicrosoft, please - get your act together. Pin
OriginalGriff21-Jul-23 2:18
mveOriginalGriff21-Jul-23 2:18 
JokeRe: Microsoft, please - get your act together. Pin
Jeremy Falcon21-Jul-23 4:51
professionalJeremy Falcon21-Jul-23 4:51 
JokeRe: Microsoft, please - get your act together. Pin
Craig Robbins21-Jul-23 6:57
Craig Robbins21-Jul-23 6:57 
GeneralRe: Microsoft, please - get your act together. Pin
Jeremy Falcon21-Jul-23 7:17
professionalJeremy Falcon21-Jul-23 7:17 
GeneralRe: Microsoft, please - get your act together. Pin
Choroid21-Jul-23 7:27
Choroid21-Jul-23 7:27 
JokeRe: Microsoft, please - get your act together. Pin
jeron121-Jul-23 7:36
jeron121-Jul-23 7:36 
GeneralRe: Microsoft, please - get your act together. Pin
Choroid21-Jul-23 7:45
Choroid21-Jul-23 7:45 
GeneralCCC 21-07-2023 Pin
pkfox20-Jul-23 23:06
professionalpkfox20-Jul-23 23:06 
GeneralRe: CCC 21-07-2023 Pin
OriginalGriff20-Jul-23 23:56
mveOriginalGriff20-Jul-23 23:56 
GeneralRe: CCC 21-07-2023 Pin
pkfox21-Jul-23 0:32
professionalpkfox21-Jul-23 0:32 
GeneralRe: CCC 21-07-2023 Pin
OriginalGriff21-Jul-23 1:45
mveOriginalGriff21-Jul-23 1:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.