The Daily WTF
Embedded chip documentation is sometimes very bad, and very confusing. Frequently it’s difficult to really understand the ins and outs of a given chip without simply getting experience.
Which is why Mr. Scrith was a bit surprised with this code, which came from someone who definitely should have known better.
This code is for a “walking 1s” memory test- it simply visits every address in memory and writes a “1” and confirms that it can read back that “1”. Such a test poses an interesting challenge: you can’t use any variables, because they will live in RAM somewhere, so you need to limit yourself only to the registers exposed by your CPU.
And that’s where this developer made their odd choice. This particular CPU had plenty of general purpose registers, and a bunch of special purpose registers, like a set of registers for controlling PWM generators. The developer either couldn’t
To read the full article click on the 'post' link at the top.