How do you get into embedded programming?

Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.
I'm not talking about programming an Arduino with everything mostly already written and with useful libraries and all that. I'm talking about real world programming where you build the electronics side of your project and then get to program the chip and optimize the code and all that.

I've done projects with Arduino, I can understand how code works but I felt that I haven't learned much. For example, I once needed to generate some signals using a MCU, and for that I needed to manipulate some registers and go really down and dirty with it. It felt so frustrating that I didn't know how all works.

So what's the way of learning all this stuff? I feel like most embedded programming books/courses imply that you already know either C programming or computer architecture.
I also got myself some STM32 boards, but most tutorials already point me towards the Arduino IDE, and I don't want to go that way again...
 
If you already have some development boards, i.e. the STM32 parts, I would look to use those if you can.

The actual microcontroller you use is largely irrelevant, although most people will always try and push their favourite brand at you. However the ST parts are good, and you can get the programmer tool cheap, about £20 for the ST-LINK/V2 in the UK, if you wanted to program them directly. The development tool from ST, System Workbench, is free to download and similar to many others. Links below.

The biggest thing is finding a project you actually want to do. Turning an LED on and off is easy in most languages, even assembler, but actually building something more complex is not. This is the real way to get into mirocontrollers.

My first true microcontroller project was an attempt at a digitally controlled audio pre-amplifier, with relay switched inputs, PGA2310 volume control, VFD display. Custom schematics, PCBs and code. It "functioned", as in the code was fine, but would malfunction with any interference from anything outside (like vacuum cleaners or fridge compressors). Used a Mircochip part, programmed from strach in Assembler and later migrated to C. Got me started and I learned a lot so no regrets. Although would like to finish it properly one day now I can.

For you it could be anything you want, something to over water the plants, custom heating controller so the heating never works, maybe an egg timer that always over cooks your eggs, or just something that works...


Links for ST bits:
Programmer

System Workbench
 
Last edited:
Embedded Systems - Shape The World: Microcontroller Input/Output

Please look into edx.org and search for embedded systems .. there are few courses as above, starting from very basics and well explained/presented ..

We may start programming ardunio in direct c language without using any ardunio libraries by referring atmel programming guides or tutorials on programming atmel microcontrollers as on ardunio board ..
 
Just saw this thread. I got into it as a career branch in 1978.
Had to decide full embedded or PC.
I went embedded and never looked back.
Devices were limited back then, cross compilers limited too etc.
I used 68701, 68705 , 875x.
Later came 68hc11 and 68xxx.
First professional project for US Corp of Engineers , second was the Midimonica a hand held pitch to midi real time converter. ( still in use at some studios)
 
I have managed to design PCBs with microcontrollers so that the "toy" board board is useful for software development before the real board is ready.
You can change package with only minor changes. Using the same programming tools as the standard boards saves a lot of time and money
 
I used to program single board computers manufactured by TDS in Forth and assembler.The primary difference is you are often programming in real time ie a conditional loop.I know a lot of products are programmed in C BUT C on a single board computer or chip is Not the same deal as C on a pc.My best advice is learn by doing,It`s cheap these days and actually a lot of fun!!!
 
I've done projects with Arduino, I can understand how code works but I felt that I haven't learned much. For example, I once needed to generate some signals using a MCU, and for that I needed to manipulate some registers and go really down and dirty with it. It felt so frustrating that I didn't know how all works.

I understand your frustration. Some of my friends experienced the same thing. Arduino can be 'mastered' in relatively very short time. But advanced robotics requires advanced programming. What students usually don't understand is that unlike 'mastering' Arduino, mastering programming takes a lifetime. If you start learning programming at the same time you start learning Arduino, yes, you will have difficulties. Sorry :(
 
I did embedded programming many years ago. My main interest has always been hardware but I needed to design some test instruments. In those days it was the Philips 8051 micro-controller designs with many spin-off versions. I started with a very simple 8051 teaching kit just to get a feel of it. Soon, I did assembler programming to control measuring instruments. Assembler programming leaves you the best control of what is going on in the hardware and if you are skilled, the most efficient code. It was fun. I temporarily used a Pascal compiler but was hampered by flaws in that compiler and irritated over the loss of absolute control.

Today the micro-controllers and CPUs are much more sophisticated. Working in assembler is only for the most simple versions.
My experience is you first need to decide what kind of constructions you will design. If more complex, decide for your programming language. C++ is very versatile but you will be working with libraries made by others that may include flaws. C++ is about finding the libraries you need in the huge public pool and try to make them work. You never have full control.

Programming is much more deterministic than building analog hardware. There is right and wrong. Analog hardware design is very often working in the gray-zone with better or less good moves.

Enjoy, it can be great fun and you learn to think in structures.
 
As a few others have suggested, learning by doing is the most interesting and fun way. I'd suggest as you have STM32 boards already and don't want to go the C route, get Mecrisp-Stellaris Forth for the board you have. That's an interactive system so you can play around with it, there are also a few helpful books on learning Forth. As Mr Evil says - give yourself a problem to solve - the trick is in making it challenging enough but not too hard. Forth lets you build it and run it as you go - fun comes because its so interactive.
 
I built my first "computer" in 1975. It used a Motorola MC6800 running at 921 KHz, with a big 2 KB of static memory. Programming was assembler, or assembler. To do that you had to learn the CPU inside and out knowing what each register did and why......fortunately, at that time there weren't too many registers and all I/O was memory mapped ( a port was written just like a memory address). It took two of us several months of learning, trying, and starting over just to get a crude image of the Starship Enterprise on our DIY 8 bit memory mapped graphics card.

Today's chips range from simple 8 bit microcontrollers that can still be programmed in assembler, to full blown 32 bit ARM core chips that are very complex, often requiring several dozen register writes just to start them up.

The first step in any embedded system task is to figure out what you want to do, then figure out what chip best suits the task, then assemble the necessary hardware, and finally write, test and debug the code.

In most cases you can start writing some code, but you must have fully functional, verified hardware before you can get very far down the test-debug cycle. How do you verify the hardware without code?

I spent 20 years in cell phone or two way radio design teams where this was a tough question to answer, and usually required some simplified hardware and test specific code to be made. I was often the hardware "maker" guy.

Today there are hundreds of Single Board Computers (SBC's) available, as well as EValuation Boards (EVB's or EVM's) from the chip manufacturers.

The Arduino is the most popular SBC, and there are plenty of "Arduino Compatible" boards with chips from the usual chip vendors on them. Yes, you can program an Arduino to do a lot, without learning the details of what's going on.

The Arduino Integrated Development Environment (IDE) can be used to hide the details such that an inexperienced programmer can make something. It can also be used to write that "test code" needed to verify that the hardware for a particular project is functional. Much of that test code can be reused in the final project.

Underneath the hood of that IDE hides the Gnu GCC compiler which can also function as a full blown C / C++ compiler. There is nothing to stop a user from writing C code to tickle any single bit in a chip, if the details of how to do this is known.

How does one learn all of these details? That is a large daunting task on today's 32 bit ARM chips. The college level text book I got for the chip on the Teensy 3.2 Arduino compatible that I used on my music synthesizer project is over an inch thick. Much of it is beyond my skill level and I have a Computer Engineering degree from 1993. Things have grown far more complex since then. I can dig through that book, and the 600 page document from NXP on the specific chip used on the Teensy to find what I need, then test it in my code.

The point here, is that by using the Teensy Arduino compatible, I know that my hardware works. I have built some simple test programs using routines on the Teensy website, and from elsewhere on the web to get the hardware functioning well enough to make sound. Then I set out to modify, rewrite or create new code to make it do what I want.

Do I completely understand everything that's going on when it runs? No, do I need to? No. I guarantee you that there is nobody on the planet that can explain exactly everything that is going on inside a modern LTE cell phone.

Similarly it is nearly impossible to understand all the details under the hood of a modern 32 bit processor, you just need to get a handle on those that matter to your particular task.

If you want to understand the basics (recommended) start with a simple 8 bit Arduino (far less to learn). Get a book that explains the inner details of the particular chip it uses. Download the data sheet for that chip. Connect up some simple hardware, maybe a couple pots, some LED's and maybe a speaker on one of the PWM pins. Download the IDE, and get "Blink" to work, then make it blink two LEDs, adjust the blink speed by the pots.

Then try to write your own "blink" in "C" by directly manipulating the registers. Try to read the internal A/D converters directly (let the Arduino code set them up). These simple tasks can be frustrating to learn, but fortunately the Arduino is so popular that information can be found.....some of it may not be completely accurate though.

I don't know if it is possible to write assembler code for an Arduino and run it through the Ardino IDE since every chip has it's own register set, and they are all different. I have not tried to use assembler in quite some time, and it's really only needed in some (usually timing) specific tasks.

The "C" language can be pretty complex as I learned it in the early 90's. A lot of the complex stuff can be ignored, and that's exactly what the basic Arduino sketch does. You can get started this way, then add in the complex parts of C as you learn them.
 
Thank you everyone for the advice. I started playing around with stm32 and got some stuff running. It's certainly much easier today than it was a few years ago when I tried it out, the (free, open source) development tools have matured and there's more APIs and libraries, not to mention microcontroller boards.
Indeed, everytime I was successful in programming an mcu I had a specific task that I needed to accomplish. Now I just need to find something to build.
 
I built my first "computer" in 1975. It used a Motorola MC6800 running at 921 KHz, with a big 2 KB of static memory. Programming was assembler, or assembler.

One of my first projects out of college was with a system running on a 6800. Then we migrated it to a 6809 and that processor was sooo much better. I also learned to write assembly language programs, that's what HW types liked to program with, didn't have to bother learning C ;)

Glad I'm not the only dinosaur around here.

Back on topic, I've done a few projects lately with ESP's, ESP8266 based boards. Basically an Arduino with built in wifi. The ESP-01 is cheap, but kind of worthless because it doesn't have enough IO available. But the slightly more expensive ESP's like a D1 mini are pretty cool. Amazing what you can get for less than $10.
I have a few around the house for IOT appliances.

Randy
 
was with a system running on a 6800. Then we migrated it to a 6809....Glad I'm not the only dinosaur around here.

I started out with a SWTPC (of Tiger amps fame) 6800 system, and also did the 6809 upgrade. By the time I was done with it, the computer took up a whole workbench, dimmed the lights when you turned it on, had 128K of bank switched static ram using 2114 chips on DIY boards, and a DIY MC6847 video card. I had it hooked up to a Teac RTR tape deck for "fast program loading" and of course the 8 inch floppy disk drive that never quite worked right. I later found out that the motor had a 50Hz pulley on it so the disk spun too fast.

Our hardware choices were based on whatever free chips we could get.....We, being the Motorola Computer club, since we all worked at a large Motorola plant. I had already ditched my machine off the workbenck by the time the Radio Shack Color Computer came out, but some of the holdouts figured out how to run CoCo software on the SWPTC boxes, since our hardware was similar.

I built this little SBC using a MC68HC11 chip in the early 1990's. It would kick the SWTPC system's butt in every way except for graphics, and run on a little wall wart.

I also built a digital fuel injection controller in the late 80's (metal box). It ran a supplemental injection system that allowed me to feed my engine more fuel than the factory injection system could flow. This allowed more turbo boost, and the fun of smoking 5.0 Mustangs with a ratty old 4 cylinder 1982 Dodge Charger.

The little purple board is today's project. It is a CS42448 Audio chip controlled with a Teensy 3.2 small SBC. It will be used in another music synthesizer project.
 

Attachments

  • HC11_EVB_top_A.jpg
    HC11_EVB_top_A.jpg
    247.8 KB · Views: 80
  • HC11_EVB_A.jpg
    HC11_EVB_A.jpg
    405.2 KB · Views: 73
  • EFI_box_A.jpg
    EFI_box_A.jpg
    265.9 KB · Views: 79
  • P2580711_x.jpg
    P2580711_x.jpg
    681.1 KB · Views: 78
Last edited:
Status
This old topic is closed. If you want to reopen this topic, contact a moderator using the "Report Post" button.