Calculating a duty cycle for PWM decoding requires the nasty division.
DutyCycle = ((unsigned long)ON_Period*100/Period);
This will defilitely work (as long as DutyCycle is USHORT anyways) but it takes around 500 cycles to resolve. After some googling there's hardly a shortage of integer division algorithms, texas presents 32/16 division assembler code in SLAA024 and the same long division algorithm is in many other places. That takes round about 230 cycles. There are also approximation divisions which seem fair bit more clever but I'm not sure how well they'd work with MSP430.
Now since neither nominator nor denominator is constant we can't use most of the fast division methods. We *do* know that the result is between 1 and 99 which should be helpful.
Short of reinventing the wheel, is there a fast algorithm to do this specific job someone has worked out to perfection a decade ago already?