Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

PIC 16F887 caveats

Status
Not open for further replies.

somepicguy

New Member
This looks like a great forum. I've spent the last few months getting started programming PICs and while they have alot of features there are some issues I've run into.
Hopefully this will help some people.

; Fixed RESET_VECTOR

RESET_VECTOR CODE 0x000 ; processor reset vector

pagesel start ; Select proper page for "start" marker
goto start ; go to beginning of program



; Fixed digital selection of PORTB IO lines- lines come up as analog
banksel ANSELH ; Select memory bank that contains ANSELH
movlw h'00' ; Move literal 00000000 to W register
movwf ANSELH ; Move W register to ANSELH

; use pagesel for all call and goto commands
; use banksel for all variable related commands



;USE THIS FOR A INTERRUPT VECTOR. SOMETIMES THE PCLATH REGISTER GETS TRASHED ON THE "GOTO INTERRUPT" and you want to ;save it first

INT_VECTOR CODE 0x0004 ; interrupt vector location
movwf w_temp ; save off current W register contents
movf STATUS,w ; move status register into W register
movwf status_temp ; save off contents of STATUS register
movf PCLATH,w ; move pclath register into w register
movwf pclath_temp ; save off contents of PCLATH register
pagesel INTERRUPT
goto INTERRUPT
 
No question, I just thought I'd put the info out there for those working with that PIC. I've had my share of banging my head against a wall trying to figure out what the issue was.

Hopefully it helps a few people.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top