alamy said:pls comment my program flow..
read input (set 31 as setpoint ; branch to TurnOn/TurnOff) and i'll have two table ....
Code:Read Movf PORTB,w Subwf SP,w ; where SP define as 31 (b’11111’) Btfss STATUS,C ; I’m not sure use this one…. Call TurnOn Call TurnOff
There are a couple of problems here, firstly why the SUBWF?, secondly 'Call TurnOff' will always execute because 'Call TurnOn' will return from it's subroutine and execute the next line.
How about this:
Code:
Read Movf PORTB,w
movwf TempW
Btfss TempW, 5 ; test bit 5
Call TurnOn
Btfsc TempW, 5
Call TurnOff
Goto Read
This assumes you wanted TurnOn and TurnOff as subroutines, because you used 'CALL'. If you used 'GOTO' instead you could remove the BTFSC line. I notice that your TurnOn and TurnOff routines don't have RETURN or RETLW at the end so you mustn't use CALL to run them, you must use GOTO instead - or add RETURN at the end of each.
The routine with GOTO then becomes:
Code:
Read Movf PORTB,w
movwf TempW
Btfss TempW, 5 ; test bit 5
Goto TurnOn
Goto TurnOff
Another way of doing it, would be to use the full 64 byte table, but for the second half of the table have bit 7 set in the entries, then after reading the table test bit 7, and turn On or OFF accordingly - remembering to mask off bit 7 before calling the delay
i've no idea on this...
If you don't understand it, just ignore it and use the existing way, it's just a variation on the same theme.