Jump to content
Sign in to follow this  
Kazuo

Picdem 2 Plus Demo Board

Recommended Posts

I installed the pic16f84a on PICDEM 2 PLUS DEMO BOARD. I am trying to get an interrupt fron the button RB0 and nothing... What should I do.

- I'm using MPLAB IDE

- PICDEM 2 PLUS DEMO BOARD http://www.cis.upenn.edu/~lee/06cse480/data/picdem2.pdf

 

Code:

 

;=== setup and configurations =============

processor 16f84A

include <p16f84A.inc>

__config _XT_OSC & _WDT_OFF & _PWRTE_ON & _CP_OFF

;=== variables in PIC RAM =================

cblock 0x0d

J

K

count1

count2

old_w

old_STATUS

endc

;=== MAIN PROGRAM =========================

org 0

goto main

;=== interrupt handler =====================

org 0x04

goto IntServ

;=== main program =========================

main:

movlw b'10111111'

option

movlw b'11111111'

tris PORTA

movlw b'00000001'

tris PORTB

clrf PORTB

bsf PORTB,0

;== setup interrupts ============================

bcf INTCON, INTF

bsf INTCON, GIE

bsf INTCON, INTE

; Flash LED

lights:

movlw b'00000010'

xorwf PORTB, f

call long_delay

call long_delay

call long_delay

goto lights

; interrupt service routine

IntServ:

btfss INTCON,INTF

goto notRB0

movwf old_w

swapf STATUS,w

movwf old_STATUS

btfsc PORTB, 0

goto exitISR

; interrupt action

movlw D'10'

movwf count2

wait:

btfsc PORTB,0

goto exitISR

decfsz count2,f

goto wait

; port-B to turn LED on and OFF

movlw b'00000100'

xorwf PORTB,f

; exit ISR

exitISR

swapf old_STATUS,w

movfw STATUS

swapf old_w,f

swapf old_w,w

; reset interrupt

notRB0;

bcf INTCON,INTF

retfie

; delay

delay:

movlw D'4'

movwf count1

repeat

decfsz count1,f

goto repeat

return

; long delay

long_delay

movlw D'200'

movwf J

jloop:

movwf K

kloop:

decfsz K,f

goto kloop

decfsz J,f

goto jloop

return

end

Share this post


Link to post
Share on other sites

Your content will need to be approved by a moderator

Guest
You are commenting as a guest. If you have an account, please sign in.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoticons maximum are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×