Referring to the PIC18F2420 datasheet (page 108), the sequece that can be used to initialize portb is as below:
CLRF PORTB
CLRF LATB
MOVLW 0Fh
MOVWF ADCON1
Referring to the PIC18F2420 datasheet (page 108), the sequece that can be used to initialize portb is as below:
CLRF PORTB
CLRF LATB
MOVLW 0Fh
MOVWF ADCON1
Hi,
If I'm not mistaken, 'CLRF LATB' is just an alternate way of doing 'CLRF PORTB'. Then in the next command, I'm simply substituting binary for hex, and since I want all 8 pins to be digital I/O's, it is 11111111b instead of '0Fh' that they are using in their illustration. I don't think I'm doing anything wrong there.
Thanks though.
Len
Hi Len,
ADCON1.5 = 1 will set AN2 as VREF- input and ADCON1.4 = 1 will set AN3 as VREF+ input. Also, bits 6 and 7 of ADCON1 are unimplemented so setting them to either one or zero will not matter.
To set complete PORTB to digital IO, set ADCON1 to 00001111b (0Fh).
Please refer datasheet page 224 for more details.
Also you can set CMCON register to 00000111b to turn off the comparator module if you are not using it.
Well, I'll be d*****! Thank you so much!![]()
Bookmarks