r/shittyprogramming • • Jun 28 '15

Embedded developer adventures

Post image
297 Upvotes

55 comments sorted by

View all comments

107

u/thorium220 Jun 28 '15

I can understand why stuff like this happens. Programmers who have only ever worked in full systems don't always have a good understanding of how embedded is different. You've got very limited resources, and often you need to get creative to ensure that your work is done fast enough.

Say you've built a data acquisition system. Your main() function is going to have two parts: the configuration section (setting all the registers), and the main while(1) loop. yes, while(1). No, I don't want to leave the loop, this processor is going to sit in place doing its thing until the head death of the universe.

My ADC is sampling at 200 samples/second. I pull this into a 16 sample dedicated ADC buffer, then pull those 16 samples into my program for work. I need to have completely finished with processing those 16 samples by the time the next 16 samples are ready, so I probably don't have time to pissfart around with fancy floats, so a library that pretends an int is a 16.16 fixed-point number is going to have to do.

Also, there's no OS. You want to dynamically allocate memory? From who? The RAM is yours. You either declare everything at compile time, or you keep careful track of what memory you have addressed (and how much of the memory will be used by the program stack). remember, I've got to finish what I'm doing in (1/200,000)*16 seconds, or I'm going to lose data. If I have to hard-cap the size of a buffer in order to make my code run at a reliable speed, you'd best believe I'm going to do it.

And yes, I have used an oscilloscope to measure the duty cycle of my microprocessor in order to make sure I won't drop any samples.

Maaaan, I miss embedded work.

21

u/kosairox Jun 28 '15

I'm actually considering trying to become an embedded systems programmer, is it worth it? I do hobby projects using uC's in my spare time and I don't want to be a "normal" programmer. Aside from programming, I enjoy electronics etc. Why did you leave embedded? How's it like?

46

u/thorium220 Jun 28 '15

Ah, I can see I've vastly over-sold my experience.

I was an embedded programmer for the 14 weeks of my required work placement in order to complete my computer engineering degree.

I have changed industries because there just aren't enough jobs for embedded programmers here in Australia, and I was unable to land one. I now audit fixed cabling infrastructure for a data cabling company.

The thing I like about embedded programming is that you work so much closer to the bare silicon. You spend so much time looking over datasheets, timing diagrams, pinouts etc, hooking up the I/O pins to an oscilloscope to check that flags are as they should be etc. There's no black box between your code and what actually goes on inside the ALU.

The reason I don't do any hobbyist embedded work is because I'm lazy, and when I get home from work all I want to do is play games and watch anime.