Jump to content


  • Content Count

  • Joined

  • Last visited

  1. 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 pinMode(GREEN_LED,OUTPUT); digitalWrite(GREEN_LED, state); pinMode(TESTPIN1, INPUT_PULLUP); // 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) TA0CTL=0b0000001000010010; 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 msCount++; if (msCount >= 18) { msCount = 0; digitalWrite(P1_6,state); // Write stepper output state=~state; // toggle state } } void TestISR() { state = !state; digitalWrite(GREEN_LED, state); }