Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
Thread Tools Display Modes
Old 16th June 2008, 12:51 PM   (permalink)
Smile PIC 16F887 caveats

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
somepicguy is offline   Reply With Quote
Old 16th June 2008, 01:00 PM   (permalink)
Default

What's the question?
__________________
Bill
Smart Kits build Smart People

http://www.blueroomelectronics.com
blueroomelectronics is online now   Reply With Quote
Old 16th June 2008, 07:10 PM   (permalink)
Default

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.
somepicguy is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Latest
Designing stopwatch with 16f887 matlark Micro Controllers 13 6th June 2008 11:19 PM
16F887 Serial Setup Mike, K8LH Micro Controllers 2 5th May 2008 12:15 PM
Can someone explain the adc? 16f887 matlark Micro Controllers 1 25th April 2008 01:29 PM
16F887 Debugging problem asp1987 Micro Controllers 0 25th March 2008 06:41 PM
I can't find the PGD and PGC pins on the 16F887... Krumlink Datasheet/Parts Requests 9 30th September 2007 06:43 PM



All times are GMT. The time now is 02:09 AM.


Electronic Circuits  |  Electronics Wiki
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.