I'm trying to get all of the pins on my 627A to just have all digital inputs and outputs, and I cant seem to achieve that after pouring through the datasheet all night.
I have a basic program test program to test the output of the pins and weird stuff happens, the problem is with PORTA.
I have this test program:
Which flashes PORTB (which works), but PORTA acts strange. First of all, port A is suppose to look flash like this
1100
0100
But port A looks like this
1000
but doesnt flash. I know the pic is doing *something* with port A because when I hook up a multimeter to port A, i dont get a constant voltage, it fluxuates from 0 to 3+ volts or so (cant measure accurately, I have a cheap radioshack multimeter).
However, when I comment out the flashing of porta like so:
The code works like it should and I get the flashing of Port B and Port A staying a constant 1100.
What am I doing wrong here? Im guessing its some sort of configuration problem since it simulates like it should in MPLAB. I thought I turned off all of the comparators and stuff but am I missing something here?
I have a basic program test program to test the output of the pins and weird stuff happens, the problem is with PORTA.
I have this test program:
Code:
LIST P=16F627A ; Define PIC
include "p16f627a.inc" ; include the defaults for the chip
errorlevel -302 ; Suppress bank warning
__config 3F43h ; WDT Off, EC Oscillator, CP off
;****************************************************************************
;* Set Up Varibles *
;****************************************************************************
COUNT1 equ 0x20
COUNT2 equ 0x21
WTEMP equ 0x26
;****************************************************************************
;* Set Up Ports *
;****************************************************************************
bsf STATUS,5
movlw 0x00
movwf TRISA
movlw 0x00
movwf TRISB
bcf STATUS,5
;****************************************************************************
;* Set Initial Conditions *
;****************************************************************************
movlw 0x07
movwf CMCON
clrf INTCON
clrf RCSTA
clrf T1CON
movlw b'1100'
movwf PORTA
clrf PORTB
;****************************************************************************
;* Main Program *
;****************************************************************************
Main
movlw 0xFF
movwf PORTB
movlw 0x08
xorwf PORTA
call LongDelay
clrf PORTB
xorwf PORTA
call LongDelay
goto Main
;****************************************************************************
;* LongDelay ~200ms *
;****************************************************************************
LongDelay
movwf WTEMP
movlw 0xFF
movwf COUNT1
movlw 0xFF
movwf COUNT2
movf WTEMP,W
LongDelayLoop
decfsz COUNT1,1
goto LongDelayLoop
decfsz COUNT2,1
goto LongDelayLoop
return
;****************************************************************************
;* End Program *
;****************************************************************************
end
Which flashes PORTB (which works), but PORTA acts strange. First of all, port A is suppose to look flash like this
1100
0100
But port A looks like this
1000
but doesnt flash. I know the pic is doing *something* with port A because when I hook up a multimeter to port A, i dont get a constant voltage, it fluxuates from 0 to 3+ volts or so (cant measure accurately, I have a cheap radioshack multimeter).
However, when I comment out the flashing of porta like so:
Code:
;****************************************************************************
;* Main Program *
;****************************************************************************
Main
movlw 0xFF
movwf PORTB
; movlw 0x08 <==Commented Out
; xorwf PORTA <==Commented Out
call LongDelay
clrf PORTB
; xorwf PORTA <==Commented Out
call LongDelay
goto Main
The code works like it should and I get the flashing of Port B and Port A staying a constant 1100.
What am I doing wrong here? Im guessing its some sort of configuration problem since it simulates like it should in MPLAB. I thought I turned off all of the comparators and stuff but am I missing something here?