Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top