AGCB Member Jul 1, 2011 #1 In Nigel's tutorial 8 (PWM) there is a bit of code i don;t understand, in the 2nd paragraph of the initialize routine. MOVF CCP1CON,w ;set CCP1 as PWM ANDLW oxof IORLW ox0c MOVWF CCP1CON Would someone explane this to me line by line with resulting values. I guess I would have done a MOVLW, MOVWF type of instruction I'm expecting to learn a new trick!!! Aaron
In Nigel's tutorial 8 (PWM) there is a bit of code i don;t understand, in the 2nd paragraph of the initialize routine. MOVF CCP1CON,w ;set CCP1 as PWM ANDLW oxof IORLW ox0c MOVWF CCP1CON Would someone explane this to me line by line with resulting values. I guess I would have done a MOVLW, MOVWF type of instruction I'm expecting to learn a new trick!!! Aaron
P Pommie Well-Known Member Most Helpful Member Jul 1, 2011 #2 He is leaving the bottom two bits unchanged. AND 0x0f zeroes the top 4 bits and IOR 0x0c sets bits 2 and 3. Mike.
He is leaving the bottom two bits unchanged. AND 0x0f zeroes the top 4 bits and IOR 0x0c sets bits 2 and 3. Mike.
Nigel Goodwin Super Moderator Most Helpful Member Jul 2, 2011 #3 Like Mike explained, it's to change specific bits only. I did it that way simply to isolate the different bit settings to show them better, rather than doing it all in one instruction.
Like Mike explained, it's to change specific bits only. I did it that way simply to isolate the different bit settings to show them better, rather than doing it all in one instruction.
AGCB Member Jul 2, 2011 #4 Thanks. I'll remember this. For me, not having hex in my head, using bin is easier with the movlw,movwf instructions. Aaron
Thanks. I'll remember this. For me, not having hex in my head, using bin is easier with the movlw,movwf instructions. Aaron