piclist 2008\07\01\100012a >
Thread: Strange PIC12F675 or user problem... pin cross-connect?
face picon face BY : email (remove spam text)(Olin Lathrop)

Rolf wrote:
>        ORG     0x004

Don't do that.  I understand recent versions of MPASM now allow ORG in
relocatable mode, but CODE allows you to explictly name the section, which
is a good idea.

>        movwf   w_temp

This is wrong without a guarantee that W_TEMP is either in unbanked memory
or reserved at the same offset in every bank.

>        movf    STATUS,w
>        movwf   status_temp

Without explicitly setting the banks between these two instructions, you
have to reserve STATUS_TEMP the same was as W_TEMP.  A better way is to
insert a CLRF STATUS between these two instructions.  Then STATUS_TEMP goes
in regular bank 0.

> ; isr code can go here or be located as a call subroutine elsewhere

It should be located here.  Some code will end up here, so it might as well
be the one routine that benefits from being at this location.  Doing a CALL
uses up a call stack slot that can't be used by the foreground code.

You also need to pay attention to PCLATH.  On machines with more than one
code page you need to save PCLATH then clear it, else local GOTO's in the
interrupt routine won't work as expected.  Since this is easy to forget, so
it's better to have your interrupt routine template include assembly time
conditional code for saving/restoring PCLATH based on whether the current
PIC has multiple code pages or not.

>        movf    status_temp,w
>        movwf   STATUS
>        swapf   w_temp,f
>        swapf   w_temp,w
>        retfi

That should be RETFIE.

Interrupt routines are a solved problem.  There is no need to reinvent the
wheel.  You can use or modify my QQQ_INTR.ASPIC interrupt routine template
that is part of my PIC develpment environment at
http://www.embedinc.com/pic.  It contains various assembly time conditionals
to configure itself to different 14 bit core PICs.

Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.
<003001c8db83$164f65c0$0300a8c0@main> 7bit

See also: www.piclist.com/techref/microchip/devices.htm?key=pic
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Strange PIC12F675 or user problem... pin cross-connect?

month overview.

new search...