Found a piece of code I don't understand

Status
Not open for further replies.

AGCB

Member
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
 
He is leaving the bottom two bits unchanged. AND 0x0f zeroes the top 4 bits and IOR 0x0c sets bits 2 and 3.

Mike.
 
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.
 
Thanks. I'll remember this. For me, not having hex in my head, using bin is easier with the movlw,movwf instructions.
Aaron
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…