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.

10

u/i_was_a_lurker_AMA Jun 28 '15

i'm working in embedded right now and all of this sang to my soul. especially trying to measure the duty cycle with an oscillloscope to diagnose erratic behavior in the adc module.

also, we totally have to use assembly from time to time. i used it last week to write an intelligent i2c slave on a uC that monitors environmental status.

1

u/[deleted] Jun 30 '15

How is the pay?

I'm doing this sort of stuff now, board controllers for r&d stuff, usb devices, uC, bit banging protocols, RPC, kernel modules, etc, but I didn't realize this was considered embedded. I don't think I'm being paid for it though.

1

u/i_was_a_lurker_AMA Jul 01 '15 edited Jul 01 '15

embedded really doesn't mean anything more than "single-purpose computer in an enclosure", so a lot of embedded stuff isn't any different (often written in Java, &c.) than general purpose computer programming (from the developer's point of view), but the stuff you're doing sounds like pretty hard-core limited-resources embedded work (isn't it hella fun? :D).

i'm still a student, so i'm paid hourly (it's an internship type of situation) and the company is a small one. i don't think i'm being paid better than i would be if i were doing non-embedded stuff at other comparably-sized companies, though.

1

u/[deleted] Jul 01 '15

isn't it hella fun? :D

Supa! I don't care for programming that just lights up pixels on a display, but making something do something in the real world is awesome.