Clears counter main movlw b00000000 initialize port a

Info icon This preview shows pages 4–7. Sign up to view the full content.

View Full Document Right Arrow Icon
;clears counter Main MOVLW B'00000000' ; Initialize Port A as Output MOVWF TRISA MOVLW B'00001110' ;Turn D4, D5, and D6 on MOVWF TRISD loop1 LOOPSWITCH BTFSC PORTD,3 GOTO LOOPSWITCH RCALL debounce RCALL INCREMENT MOVFF counter, PORTA ;PORTA←counter GOTO loop1 INCREMENT INCF counter ;counter←counter+1 INCF counter ; counter←counter+1 RETURN debounce BCF INTCON,TMR0IF ; Clear TMR0IF flag, precautionary step MOVLW 3036/256 ; Load high byte in TMR0 MOVWF TMR0H MOVLW 3036%256 ; Load low byte in TMR0
Image of page 4

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
MOVWF TMR0L MOVLW B'10000010' ; Setup T0CON 16-bit mode, Prescaler 1:128 MOVWF T0CON Checkdebounce BTFSS INTCON,TMR0IF ; Test TMR0IF flag GOTO Checkdebounce BCF INTCON,TMR0IF ; If set, clear flag & return RETURN END Code Description MOVLW: Move from literal to working register MOVWF: Move from working register to file register RCALL: Call a previously mentioned subroutine in the program TOCON: Timer Control 0 TMR0L: Timer 0 in 8-bit Timer Loopbegin: Signals the beginning of a loop BTFSC: Test specified bit of register, skip next instruction if clear GOTO: Jump to label/address (does not store return address on stack) End: This signals the end of the Program Code
Image of page 5
New Instructions
Image of page 6

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern