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.
That's why most of my systems if they really need floating point send that data to something else for processing. It's beautiful... until you have a communication issue between 7 processors...
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.