K kardzzz New Member Jun 16, 2009 #1 My project requires 5 modes. {0-4}, using a 12F683. I increment a register using ADDWF by 0x34 (dec 52). My problem is I don't understand what the PIC is doing once it encounter 'dec 260' hence see a 9 bit binary. 52 110100 104 1101000 156 10011100 208 11010000 260 100000100 (9bit) I don't have a simulator, does, it simply do a 260-255 = 5 and store b'101' ? How can I force the processor to store a '0' if above 255? Thanks
My project requires 5 modes. {0-4}, using a 12F683. I increment a register using ADDWF by 0x34 (dec 52). My problem is I don't understand what the PIC is doing once it encounter 'dec 260' hence see a 9 bit binary. 52 110100 104 1101000 156 10011100 208 11010000 260 100000100 (9bit) I don't have a simulator, does, it simply do a 260-255 = 5 and store b'101' ? How can I force the processor to store a '0' if above 255? Thanks
be80be Well-Known Member Jun 16, 2009 #2 It rolls over once it gets to 255 and starts back at 0. Don't you have Mplab It's free and can simulate your chip.
It rolls over once it gets to 255 and starts back at 0. Don't you have Mplab It's free and can simulate your chip.
P Pommie Well-Known Member Most Helpful Member Jun 16, 2009 #3 The simplest way to do it is to check the Carry flag. Code: movlw .52 ;add 52 decimal addwf Var,F ;to Variable btfsc STATUS,C ;gone past 255? clrf Var ;yes so variable = 0 Mike.
The simplest way to do it is to check the Carry flag. Code: movlw .52 ;add 52 decimal addwf Var,F ;to Variable btfsc STATUS,C ;gone past 255? clrf Var ;yes so variable = 0 Mike.
K kardzzz New Member Jun 17, 2009 #4 Thanks for your replies, I manage to solve my problem. I have mplab already but need to find time to learn more about debugging
Thanks for your replies, I manage to solve my problem. I have mplab already but need to find time to learn more about debugging