0
\$\begingroup\$

I have set a pin on a Cortex M3 to act as an rising-edge triggered interrupt and it's not firing for some reason. What it should do is receive a 1Hz pulse, trigger an interrupt and start a 12.8Khz square wave.

__main and EINT3_IRQHandler are defined in startup code created by the program, Keil uVision 5. The GPIO interrupts share the EINT3 interrupt vector with a different external interrupt. I figured it would only be a matter of activating the GPIO and EINT3 interrupts then putting the handler within the EINT3_IRQHandler label.

The GPIO interrupts are described on page 129 of this data sheet.

http://www.nxp.com/documents/user_manual/UM10360.pdf

I also tried to just set it to read the interrupt status by using

check 
    CMP [status_register], #1   ; Check interrupt status
    BEQ wave_gen                ; If triggered, start square wave
    BNE check                   ; else keep checking

and use that as a trigger but that didn't work either.

This is my code.

    AREA main, CODE, READONLY
    EXPORT __main   
    EXPORT EINT3_IRQHandler
    ALIGN
__main
    LDR     R1,=0x2009c000      ; Pointer to base of port 0 
    LDR     R2,=0x00000001      ; To control pin 0 for square wave
    LDR     R3,=0x00000001      ; For XOR to invert pin 0
    STR     R2,[R1,#0x00]       ; Set pin 0 to output mode (base+0x00)
    STR     R2,[R1,#0x14]       ; Pin 0 HIGH
    LDR     R4,=780             ; Set up timer

    LDR     R5,=0x40028080      ; GPIO Rising Edge Interrupt
    LDR     R7,=0xE000E100      ; Set EINT3-enable register

    LDR     R6,=0x00000002      ; For pin 0:1
    STR     R6,[R5,#10]         ; Activate 0:1 as rising edge interrupt

    LDR     R6,=0x00200000      ; To enable ENINT3
    STR     R6,[R7]             ; Enables EINT3
    WFI
wave_gen
    SUB     R4, #1              ; Decrement timer
    CMP     R4, #0              ; Compare to 0
    BNE     wave_gen            ; If !0, keep looping
    LDR     R4,=975             ; Reset timer
    EOR     R2,R3               ; Invert bits
    STR     R2,[R1,#0x14]       ; Invert pin
    MUL     R3,R3,R3            ; To waste cycles, ignore (1*1=1)
    MUL     R3,R3,R3
    B       wave_gen            ; Restart loop
EINT3_IRQHandler
    B       wave_gen    ; Start square wave
    ALIGN
\$\endgroup\$
  • \$\begingroup\$ If you poll the status of the input pin (i.e. read the FIO0PIN register), does the value of the input pin ever change? Perhaps you need to configure PINMODE0 or PINMODE_OD0 registers. \$\endgroup\$ – kkrambo Apr 29 '14 at 20:42
  • \$\begingroup\$ You'll drive yourself bats coding a cortex M3 in assembly \$\endgroup\$ – Scott Seidman Dec 16 '14 at 11:31
1
\$\begingroup\$

I haven't really done assembly with the cortex M3, but as far as I can tell you're not enabling the peripheral clock for whichever GPIO peripheral you are using - thats what got me the first time I did it, and what seems to catch lots of people out.

|improve this answer|||||
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.