The problem is with this statement:
Code:
LEDBrVal = (compVal - 0) * (MaxDuty - MinDuty)/(MaxADCVal - 0) + MinDuty
If compVal = 255 then that evaluates to:
LEDBrVal = 255 * 412/255 + 100

255 * 412 = 105060, which is larger than a word (which has a max of 65535)
105060 is $19a64, so the upper portion gets tossed out and you're left with $9a64 = 39524

LEDBrVal = 39524/255 + 100
LEDBrVal = 154 + 100
LEDBrVal = 254