PBP Using too many instructions
Hi, Im trying to optimise some of my code because its not running fast enough. Im trying to control PWM seperately on 24 pins. I did some tests to see what was taking so long and it seems to be the if statements.
Code:
IF 1=vPWMPos THEN
ENDIF
'Where vPWMPos is 1 the above code takes 7 instructions
'Where vPWMPos is not 1 the above code takes 8 instructions
'I also found out that the compiler does some clever optimisation
IF 1=1 THEN
ENDIF
'The above code uses no instructions at all because the compiler realises 1 will always equal 1
So, 7-8 instructions just for an if statement seems like quite a lot. Can anyone explain to me why it takes so many and if there is a away to optimise it at all.
TMR0 overflows after every 256 instructions. My if statements alone use 192 instructions. Add that to the rest of the code and it goes over 256 and this is only half the code i want to put in it. Using the prescaler isnt really an option either because that causes flickering