This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Assembly Interrupt in C Application Not Working

Other Parts Discussed in Thread: MSP430F5529

Hi Guys

I'm currently using Code Composer to develop a mixed ASM and C application for the MSP430F5529 MCU. I'm currently stuck on creating a TimerA0 Interrupt Handler. I'm using Timer A0 in Up mode to count to TA0CCR0, then to generate an interrupt when the value is reached. I would have thought that this should be using TIMER0_A0_VECTOR, but it is using TIMER0_A1_VECTOR instead when I've implemented it in C.

At this stage the C version is working, but the Assembly version is not. (Both the C and Assembly version are shown below.) When I pause the debugger after the interrupt should have happened, I always find it being caught by the following code:

$isr_trap.asm:48:49$, __TI_ISR_TRAP:
0087a0: D032 0010 BIS.W #0x0010,SR
0087a4: 3FFD JMP ($isr_trap.asm:48:49$)

It seems to suggest that no interrupt handler was found for what ever interrupt was generated. (This does not happen when running the C version.) Please note that I am not compiling the C and the Assembly versions together, I comment out one or the other for testing. For testing, I have compiled them together at one point to verify that in fact both code snippets are being compiled, proving that the assembly code and ISR naming is the same as the C equivalent.

Any arcane wizardry on the matter will be greatly appreciated.

Assembly Version

	.cdecls C,LIST,"msp430.h"

	.text
	.global TIMER0_A1_ISR

TIMER0_A1_ISR:
	bic.w #TA0IV_TAIFG,&TA0IV
	reti

	.sect "TIMER0_A1_VECTOR"
	.short TIMER0_A1_ISR
	.end

C Version

#pragma vector = TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_ISR(void)
{
  if(TA0IV & TA0IV_TAIFG)
  {
    TA0IV &= ~TA0IV_TAIFG;
  }
}

 

  • I ended up solving my own question, though someone more knowledgeable could possibly explain it better. I'm not sure if I should leave this post for other people, please advise. When looked at the vector table in debug mode, I've noticed that when I use either "TIMER0_A1_VECTOR" defined in the msp430f5529. header:

    #define TIMER0_A1_VECTOR        (52 * 1u)  

    or "TIMER0_A1" which it references in the linker script:

    TIMER0_A1    : { * ( .int52 ) } > INT52 type = VECT_INIT

    Then the generated vector table look like this:

    __TI_int51
    87A0
    __TI_int52
    87A0
    __TI_int53
    .......

    Which seem to indicate that it the interrupt vector is not being configured. However this looks exactly the same for the C implementation of the interrupt that work. Perhaps the C code generated uses offsets instead of fixed addresses as suggested by #define TIMER0_A1_VECTOR (52 * 1u).

    Regardless, the solution was to specify the section directly using:

    	.cdecls C,LIST,"msp430.h"
    
    	.text
    	.global TIMER0_A1_ISR
    
    TIMER0_A1_ISR:
    	bic.w #TA0IV_TAIFG,&TA0IV
    	reti
    
    	.sect .int52
    	.short TIMER0_A1_ISR
    	.end

    Which produce a vector table looking like this:

    __TI_int51
    87A8	8798
    __TI_int53