This code from examples:
{Sample program to read a digital input
in PORTB.4 and put the value in PORTB.5}
{$FREQUENCY 4 MHZ }
{$PROCESSOR PIC16F84A}
program BlinkLed;
var
PORTB : BYTE absolute $06;
TRISB : BYTE absolute $86;
//pin: bit absolute PORTB.7;
begin
SetAsInput(PORTB.4);
SetAsOutput(PORTB.5);
while true do
//delay_ms(1);
PORTB.5 := PORTB.4;
end;
end.
After I compiled I got this ASM code:
list p=16F84A
#include <p16F84A.inc>
;===RAM usage===
PORTB EQU 0x006
;------ Work and Aux. Registers ------
;===Blocks of Code===
0x000 goto 0x001
__main_program__:
;SetAsInput(PORTB.4);
0x001 bsf 0x003, 5 ;Bank set.
0x002 bsf PORTB, 4
;SetAsOutput(PORTB.5);
0x003 bcf PORTB, 5
;PORTB.5 := PORTB.4;
0x004 bcf 0x003, 5 ;Bank set.
0x005 bcf PORTB, 5
0x006 btfsc PORTB, 4
0x007 bsf PORTB, 5
;end;
0x008 bsf 0x003, 5 ;Bank set.
0x009 goto 0x004
__end_program__:
;end.
0x00A sleep
;--------------------
END
Clear bit before checking?
In case if
1 on PORTB.4, output PORTB.5 will make fast pulsation? Is it right?
I think will be right to make any changes in result only AFTER checking of input value.
Tried to simulate in Proteus, and found my laptop have not enough power to simulate this fast pulsation
Am I right?
PS We can see it in ASM Debugger if we change the string to PORTB.5 :=
not PORTB.4;
PORTB.5 blinking because there bcf PORTB, 5 before btfss PORTB, 4