Mixing 2 interruptions

Hi! Let’s see… I’m programming an application that requires that timer A in a msp430 causes an interruption every 2 secons and, then I trx data by usi in spi mode. The problem I have is that there’s some kind of problem and the spi interruption only happens twice and after that in the next timer interruptions nothing happens, i mean, it doesn’t make usi interruption work again…

I think is a problem with the timming, something like I’m making the spi counter start again before it could lounch the trx, but i don’t know how i can change that… (i’m working with smclk/3 and the timer is the slowest possible and the usi the fastest) Any idea or suggestion???

I’ve tried different combinations and everything seems to work till I activate a interruption (for spi or for sd16) inside the interruption handler of timer a. Is there anything that gets reseted in that interruption that i’m ignoring? Should I save some registers first?? I’m getting crazy with this…

Can you be more specific?

It is most likely that that the chip interprets your code different from what you intended.

If you are using c or other “high level languageâ€

Are you using the SPI interrupts? Are you using any other interrupts? Keep in mind that the MSP interrupts will not allow you to interrupt an active ISR. If something is keeping you from resetting the timer counter(also what timer mode are you using?), then this could explain the behavior you are seeing.

However, you have to let us know what other interrupt-driven devices you are using.

Ok, u are right, i wasn’t very specific. I’m using timerA in up mode. During the ISR I set the registers for a SPI trx, so then another interruption should be launched, the one of USI-SPI. Right now, i’m making a led light on and off (P1) during the USI ISR to see if it does something.

I’m programming in c (didn’t check the assembly code, how should I do that?).

I did the same with the SD16, using also the TimerA in up mode and it seems to work, but I cannot be sure since I cannot check the resoults.

U can see here part of the code:

interrupt(TIMERA0_VECTOR) wakeup isr_TIMERA0( void ){

if (ESTADO == TRXTIENDO){/2 check if it’s already working the SPI ISR/

return;

}

else {

ESTADO = TRXTIENDO;

USICTL1 |= USIIE;

USISR = ++sen_medidas;

USICNT = 8 ; /num de bits a trx/

}

}

/* ========================================================================== */

interrupt(USI_VECTOR) wakeup isr_PRUEBA_USI( void ){

ESTADO = ACABADO;/trx finished/

TACTL &= ~TAIE;

P1OUT ^=1<<0; /to check if it enters this interruption/

TACTL &= ~TAIE;

}

The rest of the registers have been already set in the main function.

Thanks for the help!

I forgot to say that the light goes on and off once, then never again, that’s why i thought it should be related to the timing…

“interrupt(TIMERA0_VECTOR)” will handle the interrupt generated by the “CCIFG” bit of “TACCTL0” reg. (as enabled by the “CCIE” bit). “CCIFG” will be reset automatically by the hardware.

“TAIFG” bit of “TACTL” reg. (as enabled by the “TAIE” bit) shares an interrupt vector with a few other interrupt sources. Did you handle that interrupt? Did you use TAIV? (See Section 11.2.6 of slas049e.pdf)

Thanks!! I already mend it, it had to do with desenabling the timer interruption while executing the usi one, so they don’t overlap (since I don’t need an accurate timing is not a big deal).

I’m not sure what MSP430 family you are using, but if you happen to be using one of the beefier ones, you could always take advantage of the onboard DMAs.