AnsweredAssumed Answered

IRQ causing unexpected result?

Question asked by Ryan Facer on Nov 20, 2009
Latest reply on Nov 20, 2009 by Tony Papadimitriou
I'm hoping someone here has some ideas on a problem with our code. We're using an MC68HC11E1CFN2 with external memory.

The following code snippet is in a routine that is called repeatedly in the main loop of my program. The bits in accumulator A are reversed into accumulator B then stored into a variable.

 
            LDAB  #$08        ;Load for loop counter
            STAB  INP1_TMP    ;Move 8 bits
            CLRB
GET_DIP_LP  ROLA              ;Move MSB into carry
            RORB              ;Move carry into MSB
            DEC   INP1_TMP
            BNE   GET_DIP_LP ;If not done

            COMB              ;Complement bits
            ANDB  #$3F        ;Mask off unwanted bits

            STAB  INP1_TMP    ;and save

 

The value in INP1_TMP is what I expect. I don't know how often this code gets executed (don't have a debugger) but I'd say it does what it should thousands of times in a row, but every once in a while the value in INP1_TMP is incorrect.

This routine also gets called in my interrupt handling code.

Any idea what could be going wrong? My only theory is that occasionally in between the ROLA and RORB statements, an interrupt happens (and the code executes again) and when it returns the carry bit is incorrect. That should have been saved correctly on the stack though.


It looks like if I don't call this routine in the interrupt handling code everything works fine. I'd still like to know what's going wrong though.


Thanks,

Ryan

Outcomes