Hiya!
So I have a 328p on a board and it functions as a source for PWM, either phase correct or up counting depending on mode of operation.
My development process requires me to gradually hike the PWM up after making changes to a board, because an unpredicted element or any error and the whole thing will break.
I can also not allow glitches here. It's a high EMI environment once the PWM is on.
Low or zero value PWM is inconsequential. Accidentially high duty is bad.
I want to hack something on to my board that lets me speed this up without having to reprogram.
My thoughts how to do this are as follows:
I will run code to adjust the PWM once in the setup() function and not update it during runtime. This is to make sure EMI does not fuck with the reading. I will place a row of jumpers that encode the desired setting. The jumpers will pull down as to defeat EMI and loose jumpers. A jumper being placed leads to the duty to increase. So again: This is meant to lead to a safe design, where a loose or forgotten jumper is not catastrophic.
I have plenty of open pins on the board.
So assuming I want 8 bit resolution I plan to reserve 8 pins (17, 18, [22,26], 28) for this, first set them to input, active pullup, delay, and then read each pin and shift it into a byte. When done pass this byte to the register like OCR1A.
Then main empty while(1)
What could go wrong? Is there a better way to do this? I want discrete steps and a low impedance environment. Again: I think a pot is too risky. I might even make entire 8 bit jumpers and key and mark them as to not make mistakes.