12f675 IO question

Discussion in 'Embedded Systems and Microcontrollers' started by Man_in_UK, Jul 17, 2008.

  1. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    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 ?
     
  2. Man_in_UK

    Thread Starter Senior Member

    May 13, 2008
    132
    0
    Bump
    Sorry but I still don't get it.
     
  3. AllVol

    AAC Fanatic!

    Nov 22, 2005
    55
    2
    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: Aug 6, 2008
Loading...