Hi there. I'm trying to make a simple testing circuit which would scan PORTB, 0 for changes (from 0 -> 1) and upon doing so, it will send 0x1 to PORTA. Meaning when button is pressed, PORTA,0 will turn to 1. Here's my code:
But in the simulator, nor when testing on chip, this does not work! Please help. what is wrong with my code??! I read the manual for PIC16F84A and it seems that I am doing everything right. For some reason, the 'goto change' line is always skipped even when I put PORTB,0 high. I use "PIC Simulator IDE" to test my program.
Thanks much!!!
Rich (BB code):
title "Program"
include "p16f84a.inc"
__CONFIG _CP_OFF & _WDT_ON & _PWRTE_ON & _RC_OSC
;===== variables ===========
count1 equ 0xc
count2 equ 0xd
;===== end variables =======
ORG 0x000
;===== set ports ======
bsf STATUS,RP0 ;set PORTB, 0 to input, others to output
movlw 0x1
movwf TRISB
movlw 0x0
movwf TRISA
bcf STATUS, RP0
; ====== end setting ports ======
start:
BTFSC PORTB, 0
goto change
goto start
change:
movlw 0x1
movwf PORTA
return
end
Thanks much!!!