0
votes

Trying to write an ISR in assembly for when a button gets pressed on my MSP430. I've followed some instructions around the web, but I'm having trouble "linking" the ISR to the button press.

Specifically, I'm trying to get a button attached to port P1.1 to run my ISR.

Steps I've done

1) Enable the interrupt for P1.1 P1IE |= BIT1;

2) Selected H->L transition: P1IES |= BIT1;

3) Cleared flag register: P1IFG &= ~BIT1;

4) Enabled global interrupts: __enable_interrupt();

Still though, I think I'm missing something. I don't understand how to tell the program to run my ISR, and unfortunately I have not found any guidelines on the web that are very clear about this part. Here is my ISR in assembly:

    .cdecls C,LIST,"msp430.h"
    .sect ".text:_isr"

buttonISR:      push R4
                mov.w #1000, R4
loop:           dec.w R4
                jnz loop
                reti


    .sect BUTTON_ISR
    .word buttonISR
    .end
1
I'm not familiar enough with the MSP430 specifically to answer the question, but with most architectures, you have to register the ISR by putting its address in the slot of the interrupt vector table the corresponds to the IRQ you want to handle.reirab
Does that assembly language distinguish between labels with a trailing colon and those that don't? If so, what is the difference?wallyk
Ok @reirab, yes I have heard about this interrupt vector table, but I'm unsure of how to use it at this point. @wallyk Sorry, that was a typokrb686
You don't seem to be setting the interrupt number you want generated when you press the button (using P1IV register). You're mixing old style (.sect/.word) and new style (.intvec) ways of declaring interrupt vectors. You also got the old style wrong, it should be .word buttonISR.Ross Ridge
Thanks Ross. My code is a coagulation of bits and pieces I've seen in various places of the web, so I'm not surprised. I haven't found a resource yet that explains these things as clearly as I need. So then, I removed .intvec... because I'm assuming that does the same thing as the .sect/.word portionkrb686

1 Answers

1
votes

Okay I figured it out. Apparently the interrupt vector table is a hard-coded memory space. From the datasheet, I found that the interrupt vector for port 1 was 0xFFDE, which translates to INT47, thus I changed the bottom part of my assembly program to:

.sect ".int47"
.word buttonISR
.end

And now it works beautifully!