Hello!
I've got an issue with using __delay_cycles() while also utilizing
TimerA interrupts.
It seems that __delay_cycles(); is not working if TimerA interrupts
are enabled. Even if nothing is done in interrupt routine.
Here is a sample code:
========== main.c ============
#include <msp430g2553.h>

// Timer A0 interrupt service routine (at top value)
#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A0 (void) {
    TACCTL0 &= ~(TAIFG); // clear interrupt  flag
}

// Timer A1 interrupt service routine (in the middle)
#pragma vector=TIMER0_A1_VECTOR
__interrupt void Timer_A1 (void) {
    if (TACCTL1 & TAIFG) {
        TACCTL1 &= ~(TAIFG); // clear interrupt  flag
    }
}

int main(void) {
    WDTCTL = WDTHOLD | WDTPW; //halt watchdog
    P1REN = ~(BIT6); // pull-ups are disabled on pins 0 and 6
    P1DIR |= BIT6; // pins 0 and 6 are outputs
    P1OUT &= ~(BIT6); // pin 6 and pin 0 are LOW

    TACCR0 = 0x0fff; // set top value for timerA
    TACCR1 = 0x00ff; //set LED glow power
    TACCTL0 = (CCIE); // enable compare interrupt for TACCR0
    TACCTL1 = (CCIE); // enable compare interrupt for TACCR1
    TACTL = (TASSEL1 | MC0 | TACLR | TAIE); // SMCLK, cnt UP, clear, interrupt
    _BIS_SR(GIE); // enable blobal interrupts
    for (;;) {
        P1OUT ^= BIT6;
        __delay_cycles(1000000);
    }
    return 0;
}
======== end of main.c =============

I expect this code to blink with a LED on P1.6 with approximately 1
second interval (no precise timing required). But all I see is the LED
just lit all the time.
If I comment out the line with _BIS_SR(GIE); the LED is blinking as expected.

What could be the reason? My guess is interrupt routine is somehow
spoiling registers used by __delay_cycles(). Is that true?
Would be thankful for a workaround if there is such.

I'm using msp430-gcc (GCC) 4.6.3 20120301 (mspgcc LTS 20120406
unpatched) from Debian repository to build code for TI Launchpad
MSP-EXP430G2 (M430G2553 chip).

Thank you!
--
Best regards,
Kirill Popov.

----
Other ways to contact me:
Gtalk: kirill.s.po...@gmail.com
Cell phone: +79052062619
LinkedIn: http://ru.linkedin.com/in/kspopov

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to