The WHY is 2 fold.
1. There's a CLRWDT in there. That can be eliminated with the NO_CLRWDT define.
2. PBP doesn't optimize Page switching as well as it does BANK switching. So before it can jump past the code (if the condition is false), it sets BOTH page bits, whether it needs to or not. And in most cases, it doesn't need to.
But even if you eliminated both of those issues with an ASM macro, it would still take 4-5 instructions, for a total of 120 cycles. Better, but not Best.
To really make it faster ... use the BRANCH or BRANCHL command. Then instead of 24 IF statements, it jumps right to the section it needs to be in, according to the the vPWMPos variable.
Branch will take about 16 instructions, BranchL will take a few more.
<br>
Bookmarks