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.

MSP430F5529: MSP430F5529 ISR Question

Part Number: MSP430F5529
Other Parts Discussed in Thread: MSP-EXP430F5529LP

Hello All, I am new to embedded programming. I started with MSP-EXP430F5529LP and tried to follow a great blog series https://embedded.fm/blog/ese101 by Chris Svec

In one of his blogs (https://embedded.fm/blog/ese101-interrupts-blink), the author was using ISR (trigger by a push buttom switch GPIO 1.1) to blink a LED (GPIO 1.0). I follow what he did successfully and then I wanted to create another ISR to use another push buttom switch (GPIO 2.1) to blink another LED (GPIO 4.7).

Following is my code in assembly:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
; Set GPIO P1.0 to be an output (P1DIR bit 0 == 1)
BIS.B #0x01, &P1DIR
; Set GPIO P1.1 to be an input (P1DIR bit 1 == 0)
BIC.B #0x02, &P1DIR
; Set GPIO P1.1 to be pulled up or down (P1REN bit 1 == 1)
BIS.B #0x02, &P1REN
; Set GPIO P1.1 as a pull-up resistor (P1OUT bit 1 == 1)
BIS.B #0x02, &P1OUT
; Set interrupt on high-to-low transition of P1.1
BIS.B #0x02, &P1IES
; Clear any interrupts that happened when changing P1IES
BIC.B #0x02, &P1IFG
; Enable P1.1 interrupts
BIS.B #0x02, &P1IE
;-------------------------------------------------------------------------------
; Set GPIO P4.7 to be an output (P4DIR bit 7 == 1)
BIS.B #0x80, &P4DIR
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

When I run my code on the eval board, it works flawlessly for PORT1_ISR:. ISR PORT1_ISR: is executed when GPIO 1.1 is engaged. It returns to the MainLoop after ISR finishes. However, when I tried PORT2_ISR, GPIO 2.1 triggered the ISR, but upon finishing, it didn't return to the MainLoop. Instead, it keeps looping in this ISR indefinitely. Is there something I did wrong here?

Thanks

Yi

  • I played it abit more, it looks like register P2IFG1 is never cleared even the push button switch is released. If I manually clear it in the Register window in CCS, ISR returns as it should have. Any idea why this bit wasn't been cleared?

  • More information, I noticed that GPIO 2.1 could be used for other functions which is controlled by register P2SEL, so I added the following statement in my code, but it doesn't make any difference:

    Fullscreen
    1
    BIS.B #0x00, &P2SEL
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • > BIC #0x02, &P2IFG

    I think you need

    > BIC.B #0x02, &P2IFG

    The implied BIC.W reads from the word at the address, and P2IFG is at 0x1D so it clears 0x02 at address 0x001C.

    The P1IFG reference should also be BIC.B, but it works by accident since the address of P1IFG is word-aligned (0x001C)

  • Indeed, it solves my issue. Should have paid more attention in this. Thanks.

**Attention** This is a public forum