robert.rozee Guru Joined: 31/12/2012 Location: New ZealandPosts: 2542
Posted: 11:38am 27 Aug 2022
the downside with an extra parameter is that it requires additional complexity in the interpreter to decode it: distinguishing between a letter ("P") and a number, generating an error if it is the wrong letter, etc. in the case of the MX170 at least, there is almost no spare flash available for this sort of thing.
a negative frequency, on the other hand, can be checked with just a couple of machine code instructions. then a couple or three more instructions to divide the frequency by -2, and a single poke to change the PWM configuration register. potentially it may only involve growing the firmware by a handful of bytes - a far smaller barrier when flash space is scarce.
it also means the new feature can be 'silently slipped in' without needing to document it