;pbtest.asm ; Test the push buttons by putting the value on the led bar ; The push buttons are interfaced through RB7-RB0. The diagram in the Raven manual is not ; quite correct. PB1 is the black button, and is connected to RB7, not RB4. Similarly, ; RB6 is connected to yellow, RB5 to red and RB4 to green. ; ; Be careful! One of the settings that is necessary in order for the buttons to work ; is to clear bit 7 of the option register (also known as the NOT_RBPU bit). When cleared, ; a weak pullup resistor is applied to the B pins, resulting in a default value of 1 on ; all of the pins. Then, when the button is pressed, the value on the pin is driven ; low (zero). ; LIST P=16F877, R=DEC INCLUDE "P16F877.inc" ; Definitions ; __CONFIG _CP_OFF & _DEBUG_OFF & _WRT_ENABLE_OFF & _CPD_OFF & _LVP_OFF & _BODEN_OFF & _PWRTE_ON & _WDT_OFF & _HS_OSC ; Variables ScratchPad EQU 0x20 Temp EQU ScratchPad+0 ; Start of the Program ORG 3 goto Start ORG 0x50 Start bsf STATUS,RP0 clrf TRISA clrf TRISD movlw b'11110000' movwf TRISB bcf OPTION_REG, 7 ; This controls the pullup registers bcf STATUS,RP0 pbloop ; Get the state of the push button outputs movlw 0x1C movwf PORTA fill (nop), 10 ; Give the buffer outputs time to settle movf PORTB,W andlw 0xF0 ; and output them for all to see call DispLedBar goto pbloop DispLedBar ; Enable the led bar and put the value in W there. movwf Temp ; save W movlw 0x12 movwf PORTA comf Temp,W movwf PORTD return END