12f675 IO question

Thread Starter

Man_in_UK

Joined May 13, 2008
180
I don't understand this bit !

In the demo lessons of the PicKit flash 12f675 these 2 lines are included in the Init section of all 3 lesson 1 examples ....

movlw CM2 | CM1 | CM0 ; configure comparator inputs as digital I/O
movwf CMCON


It would appear that they turn the comparator off and set digital I/O's.



I am having a problem getting GP2 to act as a simple digital output. I found that removing those 2 lines from the code I can get GP2 to work as expected. Is this example wrong or am I just not gettin it ?
 

AllVol

Joined Nov 22, 2005
55
I don't understand this bit !

In the demo lessons of the PicKit flash 12f675 these 2 lines are included in the Init section of all 3 lesson 1 examples ....

movlw CM2 | CM1 | CM0 ; configure comparator inputs as digital I/O
movwf CMCON


It would appear that they turn the comparator off and set digital I/O's.



I am having a problem getting GP2 to act as a simple digital output. I found that removing those 2 lines from the code I can get GP2 to work as expected. Is this example wrong or am I just not gettin it ?
You are right in thinking the comparator is to be turned off. Setting the three bits <CM2:CM0> will accomplish this.

movlw 0x07 ; or b'00000111'
movwf CMCON0

GP2 then automatically becomes I/O
 
Last edited:
Top