Truncated match.
PICList
Thread
'simple polling'
2000\02\05@173509
by
sep
|
Hello,
I have just gone through doing a led flasher and now moving to learn how to
use input on the PIC16f84. I am trying to get this piece of code working. It
is SUPPOSED to keep on led on pin RB1, then when pin RB0 = low, led on RB2
is lit.
This code was originally got from http://www.rentron.com/Myke5.htm but that
did not even work. So, I changed it and it still does not work!
I tried it on the MLAB simulator and it seems to be working as I want it?
Any body see anything wrong?
Thanks for the help,
Sep S.
====
#include "p16f84.inc"
LIST P=16F84, R=DEC
; Register Usage (nothing there...)
CBLOCK 0x00C ; Start Registers at End of the Values
ENDC
__CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF
; Note that the WatchDog Timer is OFF
; Note: B0 : mommentarily on push button
; B1 : lit at all times!
; B2 : lit if button is being pushed
ORG 0
BSF STATUS,RP0 ; select bank 1 (need to go to bank 1 since trisb is there!)
MOVLW 0x01 ; turn b0:input, b1,2:output
MOVWF TRISB ; apply it to trisb register
BCF STATUS,RP0 ; select bank 0 (come back!)
BSF PORTB,1 ; turn on led on B1 (and keep lit)
Loop
BTFSC PORTB,0 ; Is the Button Pressed?
GOTO ButtonPressed ; turn it on ....
BCF PORTB,2 ; Turn off LED B2 off
GOTO Loop
ButtonPressed ; Button Pressed, Turn LED on
BSF PORTB,2
GOTO Loop
END ; end it...
2000\02\05@201500
by
Sebastian Garcia
|
Sep,
-----Original Message-----
From: sep <spam_OUTsseyediTakeThisOuT
hypervr.com>
To: .....PICLISTKILLspam
@spam@MITVMA.MIT.EDU <PICLIST
KILLspamMITVMA.MIT.EDU>
Date: Saturday, February 05, 2000 7:47 PM
Subject: simple polling
|Hello,
|
|I have just gone through doing a led flasher and now moving to learn how to
|use input on the PIC16f84. I am trying to get this piece of code working.
It
|is SUPPOSED to keep on led on pin RB1, then when pin RB0 = low, led on RB2
|is lit.
|This code was originally got from http://www.rentron.com/Myke5.htm but that
|did not even work. So, I changed it and it still does not work!
|
|I tried it on the MLAB simulator and it seems to be working as I want it?
|
|
|Any body see anything wrong?
|
|
|
|Thanks for the help,
|
|Sep S.
|
|====
|#include "p16f84.inc"
|
| LIST P=16F84, R=DEC
|
|
| ; Register Usage (nothing there...)
| CBLOCK 0x00C ; Start Registers at End of the
Values
| ENDC
|
|
| __CONFIG _CP_OFF & _XT_OSC & _PWRTE_ON & _WDT_OFF
| ; Note that the WatchDog Timer is OFF
|
|
| ; Note: B0 : mommentarily on push button
| ; B1 : lit at all times!
| ; B2 : lit if button is being pushed
|
|
| ORG 0
|
| BSF STATUS,RP0 ; select bank 1 (need to go to bank 1 since
trisb is there!)
| MOVLW 0x01 ; turn b0:input, b1,2:output
| MOVWF TRISB ; apply it to trisb register
| BCF STATUS,RP0 ; select bank 0 (come back!)
| BSF PORTB,1 ; turn on led on B1 (and keep lit)
|
|Loop
| BTFSC PORTB,0 ; Is the Button Pressed?
Note that, as You said in the lines above, with the button pressed You have
a '0' in RB0 pin.
In this case, You will need to use the instruction BTFSS in place of BTFSC,
to mantain the LED off while the button is not pressed ('1' logic because of
the pull-up in pin RB0 I assume You've connected in the pin)
| GOTO ButtonPressed ; turn it on ....
| BCF PORTB,2 ; Turn off LED B2 off
| GOTO Loop
|
|ButtonPressed ; Button Pressed, Turn LED on
| BSF PORTB,2
Here You must add a delay to see the LED on (with hundreds of ms. You will
see it clearly), and to "software debounce" the swith.
| GOTO Loop
|
| END ; end it...
Regards,
S.-
More... (looser matching)
- Last day of these posts
- In 2000
, 2001 only
- Today
- New search...