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

Matthew Miller wrote:
> ... but I wanted to post the ISR code that ...
> it has always worked with the 16F and 12F parts

Note that the 12 bit core parts don't have interrupts, so the 12F part you
refer to are really misnamed 14 bit core parts.

>         ; The ISR begins here at program location 0x04.
>         movwf   w_temp      ; copy W to temp register

You didn't show how the variables were defined.  W_TEMP must be in unbanked
memory or multiply defined at the same offset in every bank.

>         swapf   STATUS, W   ; swap status to be saved into W

You should insert a CRLF STATUS here.  That selects a predictable bank.  If
not then you either have to reserve STATUS_TEMP, PCLATH_TEMP and FSR_TEMP in
unbanked memory or at the same offset in all banks.  Unbanked memory is
usually precious, and reserving the same variable in multiple banks is a

>         movwf   status_temp
>         movf    PCLATH, W
>         movwf   pclath_temp
>         movf    FSR, W
>         movwf   fsr_temp

I put assembly time conditionals around saving PCLATH and FSR so that they
only get saved/restored when appropriate.  Also, you forgot to clear PCLATH
after saving it.

>         ; ISR goes here...
> leave_isr

bank 0.

>         movf    fsr_temp, W
>         movwf   FSR
>         movf    pclath_temp, W
>         movwf   PCLATH
>         swapf   status_temp, W  ; swap STATUS_TEMP register into W,
>         sets bank to original state movwf   STATUS          ; move W
>         into STATUS register swapf   w_temp, F       ; swap w_temp
>         swapf   w_temp, W       ; swap W_TEMP into W
>         retfie

This got garbled so I didn't look at it closely.

Again, a 14 bit core interrupt routine is a solved problem.  Even if you're
not using my PIC development environment (http://www.embedinc.com/pic), you
can mostly copy my interrupt template routine QQQ_INTR.ASPIC.  It has all
the details taken care of.  Too many of you are trying to reinvent the
wheel, and then getting it wrong on top of it.

Embed Inc, Littleton Massachusetts, http://www.embedinc.com/products
(978) 742-9014.  Gold level PIC consultants since 2000.
<012201c8dc34$1ca25570$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...