Hi I've been asking a lot of questions lately so try to bear with me. I am trying to configure GPIO 0,1 and 2 to be digital outputs. I can get GPIO 0 and 1 to send me a logic of 5V but when I call the setGP2 function I don't get a high output on GPIO 2. My TRISIO register is set up as B'00001000' and cleared ANSEL so all of them would be digital outputs except GPIO 3 being always a input. Do I also have to alter the CMCON? What do the bits signify it doesn't really say much in the datasheet. Here is my code:
Rich (BB code):
list p=12f675 ; list directive to define processor
#include <p12f675.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _CPD_OFF & _BODEN_OFF & _MCLRE_OFF & _WDT_OFF & _PWRTE_ON & _INTRC_OSC_NOCLKOUT
;*************************** DEFINE STATEMENTS ********************************
; Register Bank Directories
#define Bank0 banksel 0x00 ; first registerr bank = Bank 0
#define Bank1 banksel 0x80 ;second register bank = Bank 1
#define Blank B'00000000' ; All LEDs off
#define ConfigTRI B'00001000' ; Configure I/O
;#define Counter 0FFh ; hex vale xFF
;****************************** Start of Program ******************************
org 0x000 ; processor reset vector
goto Initialize
;******************************************************************************
; Initialize
; Initialize Special Function Registers
;******************************************************************************
org 0x005 ; Start of Programm Memory Vector
Initialize
Bank1 ;Bank 1
clrw
clrf ANSEL ;Digital I/O
movlw ConfigTRI ;Set GP5,4,2,1, and 0 as outputs
movwf TRISIO ;and set GP3 as singular input
Bank0 ;Bank 0
clrw
clrf GPIO ;Init GPIO
movlw 07h ;GPIO as all digital
movwf CMCON ;digital IO
;clrw
;movlw Counter
Main
;call setGP0
;call setGP1
call setGP2
;call clearGP
goto Main
clearGP
movlw Blank ; clears pins of GPIO
movwf GPIO ; move value in w to register GPIO
return
setGP0
movlw B'00000001' ; set GPIO 0
movwf GPIO ; move value in w to register GPIO
return
setGP1
movlw B'00000010' ; set GPIO 1
movwf GPIO ; move value in w to register GPIO
return
setGP2
movlw B'00000100' ; set GPIO 2
movfw GPIO ; move value in w to register GPIO
return
end