Jump to content

MSP430F5529LP timer interrupt prevents external interrupt

Recommended Posts

Thanks in advance for helping.  New to microcontrollers, not fluent in C so would prefer higher level language like Energia.

Using an MSP430F5529LP to drive a stepper motor, creating a square wave using timer A interrupt handler.  That works fine, but would like an additional input to the MSP to increase/decrease the speed.  In the following code, the external interrupt is detected when the TA0CCR0 assignment is commented out.  With the line included, the external interrupt is not recognized.  Thanks again.




int TESTPIN1 = P1_5;
int state = LOW;

void setup()
  // put your setup code here, to run once:
  pinMode(P1_6,OUTPUT); // step motor clock output
  digitalWrite(GREEN_LED, state);

  // Configuration word
  // Bits 15-10: Unused
  // Bits 9-8: Clock source select: set to SMCLK (16MHz)
  // Bits 7-6: Input divider: set to 1
  // Bits 5-4: Mode control: Count up to TACCRO and reset
  // Bit 3: Unused
  // Bits 2: TACLR : set to initially clear timer system
  // Bit 1: Enable interrupts from TA0
  // Bit 0: Interrupt (pending) flag : set to zero (initially)
  TA0CCR0=1200; // Set TACCR0 = 2000 to generate a 1ms timebase @ 16MHz with a divisor of 8
  TA0CCTL0=BIT4; // Enable interrupts when TAR = TACCR0

  attachInterrupt(digitalPinToInterrupt(TESTPIN1), TestISR, CHANGE);


void loop()
  // put your main code here, to run repeatedly:

#pragma vector=TIMER0_A0_VECTOR
__interrupt  void timerA0ISR(void)
// Timer A0 Interrupt service routine
  static int msCount=0;// Count milliseconds to allow a 1 second pulse
  static int state=0;  // Remember state for toggling purposes
  if (msCount >= 18)
    msCount = 0;
    digitalWrite(P1_6,state); // Write stepper output
    state=~state;             // toggle state

void TestISR()
  state = !state;
 digitalWrite(GREEN_LED, state);

Link to post
Share on other sites

I didn't realize this was energia.......

and cant answer Energia code questions.

There is something i did notice.

There is no #pragma vector=  for your Pin interrupt. I dont know how this affects energia.

I use in my code something like this to test.


// Port 1 interrupt service routine
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
  P1OUT ^= BIT0;                            // P1.0 = toggle
  P1IFG &= ~BIT4;                          // P1.4 IFG cleared




Link to post
Share on other sites
On 11/19/2018 at 4:24 PM, jsolarski said:

Im a little rusty, but i thought you cant service interrupts within interrupts and if an interrupt comes through while running an interrupt it would ignore it.

This is my understanding as well. Placing interrupts inside interrupts is best left to the experts. I am not one of them.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...