Thursday, September 15, 2011

PSV considered harmful

"My motor control ISR's use lookup tables in PSV, most of my PID or FIR control interrupts use coefficients in PSV for the DSP to save RAM..."

https://www.microchip.com/forums/m241389.aspx

Aside from the acronymorrhea, it's really an interesting discussion. One poster insists certain practices are "not safe", while others say they're perfectly fine. Both have valid points.

Many things are not safe if you do not take appropriate precautions. Nested interrupts really can cause problems on non-atomic operations. But that doesn't mean you don't use nested interrupts, it just means you disable them for the duration of any non-atomic operations.

Simon Tatham, speaking of the hoops he went through to implement coroutines in C, said "Any coding standard which insists on syntactic clarity at the expense of algorithmic clarity should be rewritten." Obviously that's not 100% realistic. But neither is assuming you can meet an arbitrary syntactic coding standard 100% of the time. The balance lies in knowing when to break what rules.

No comments:

Post a Comment