AquaticTechTank.net
http://aquatictechtank.net/

PIC16F84A, problems giving PORTA a value
http://aquatictechtank.net/viewtopic.php?f=35&t=203
Page 1 of 1

Author:  chulian [ Fri Apr 14, 2017 10:51 pm ]
Post subject:  PIC16F84A, problems giving PORTA a value

Hello:

I have the following code to send a 1 though PORTB[0] when PORTA[2] = 1; the problem is that the value b'000001000' is never stored in PORTA, i don't know why and i use the variable "aux" to verufy this, when i move the value from PORTA to aux it comes as 00 when i already supposedly have given PORTA the value of b'00000100', any idea of what is going wrong? Thank you

PS: i'm using MPLABX IDE v 3.55, running on windows 10
The datasheet of PIC16F84A:http://www.kynix.com/uploadfiles/pdf65976/PIC16F84A-042fP_607407.pdf
Code:
list p=16f84a ;Tipo de dispositivo
;Zona de etiquetas
STATUS EQU 0x03
PORTA EQU 0x05
PORTB EQU 0x06
TRISB EQU 0x86
TRISA EQU 0x85
RP0 EQU 0x05
aux equ 0x41
ORG 0
Goto INICIO
ORG 5

INICIO
bsf STATUS, RP0 ; Goes to Bank1
clrf PORTB ; PORTB as output
movlw b'00000100' ; Bit 2 of A as input
movwf PORTA
bcf STATUS, RP0 ; goes to bank0
clrf PORTB ; clears portB
movlw .5
movwf aux
movf PORTA, 0
movwf aux
BUCLE
btfss aux, 2 ; if (RA2 = 1 )
goto TOFF ; => turn off
goto TON ; [] turn on
TON
bsf PORTB, 0 ; RB0 = 1
goto BUCLE
TOFF
bcf PORTB, 0 ; RB0 = 0
movlw .4 ; Bit 2 of A as input
movwf PORTA
goto BUCLE

END

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/