Posted 3 hours ago

/

8 comments

/

embeddedartistry.com

37 minutes ago by barbegal

>Keep ISRs small

I disagree. If you have interrupt priorities then you can treat your interrupt service routines as the highest priority tasks. As an example lets imagine a drone controller which has two functions it needs to perform in real time: it needs to vary the PWM signal to the motor controller and it needs to acknowledge radio packets. An interrupt is raised when the accelerometer has new data and another is raised when the radio has received a packet. You could write ISRs which just queues the accelerometer data and radio packets so they can be dealt with by a flight control task and a radio task respectively. Alternatively, you could run the whole of the flight controller inside the accelerometer ISR. This reduces copying of data and context switches. Because the accelerometer ISR now takes longer you need to use the radio ISR to acknowledge the radio packets itself. You split the radio task into two tasks: a low priority task for processing commands and the ISR task which does the acknowledgements.

> Avoid blocking function calls

This can be rewritten as never call functions that block on an action of a lower priority task. It leads to priority inversion in normal tasks and deadlocks in ISRs.

13 minutes ago by nsajko

> I disagree. If you have interrupt priorities then you can treat your interrupt service routines as the highest priority tasks. ...

I think "Keep ISRs small" is still a good guideline for most cases. Big interrupt handlers require more system-wide knowledge to verify (e.g., stack space, maximal latency, priority problems, ...). They introduce more coupling into the system, in other words.

Of course, this should not be some hard rule, rather just a rule of thumb. I wouldn't like it if some policy like this prevented you from choosing the optimal solution in a case like you suggested.

42 minutes ago by PoachedSausage

> Every sensor is a temperature sensor. Some sensors measure other things as well.

Some components can become sensors under the right conditions. Example: Components becoming microphonic.

At high enough frequencies digital design becomes analogue design.

9 minutes ago by bfrog

So true!

10 minutes ago by bfrog

I feel like half of what's here points to using rust or a rust like language as a good thing. Even I suppose C++ if you can use the pointer types to help yourself.

4 minutes ago by nsajko

> I feel like half of what's here points to using rust or a rust like language as a good thing.

Which points exactly?

Neither the Rust standard library, nor the C++ "smart pointers" were designed with embedded in mind. Also, Rust is kind of experimental, not really a good choice for a system that is difficult to update. Not to mention only Intel and AMD64 platforms have Rust Tier 1 support.

2 hours ago by disposedtrolley

With the exception of some of the rules under the Hardware section, this is some great succinct advice on software development in general :)

an hour ago by jpm_sd

Well, they're all good rules, but nobody is going to remember them in the form of a cluttered bulleted list.

Jack Ganssle is quoted repeatedly - his blog has a lot of good war stories that illustrate many of these points in much greater detail.

http://www.ganssle.com/blog/index.html

Daily Digest

Get a daily email with the the top stories from Hacker News. No spam, unsubscribe at any time.