Hello everyone.
I'm new to this forum and i am trying to drive a stepper motor using MSP430F417. What I want to do is just let the motor stop after a certain angle of rotation.
I am writing my code in CCS and as there are not many examples on the internet, I am quite confused. Could you please tell me where I made a mistake?
here is my code:
here is my code:
#include <msp430.h> #define SM_clk 1000000 #define servo_freq 50 #define Stepper BIT4 int step=0; void main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer __bis_SR_register(LPM0+GIE); int PWM_periyot =SM_clk/servo_freq; P1DIR = 0xFF; P2DIR = 0XFF; P3DIR = 0xFF; P4DIR = 0XFF; P5DIR = 0xFF; P6DIR = 0XFF; P2IE |= BIT1; P2IES |= BIT1; P2IFG &= BIT1; CCR1 = TAIE; TA1CCR1 = PWM_periyot; TA1CCR1 = 0; TA1CCTL1 = OUTMOD_7; TA1CTL=TASSEL_2+MC_1; . } #pragma vector=TIMER1_A0_VECTOR __interrupt void Timer_A(void){ switch(TA1IV){ case 0: TA1CCR1 = 600; __delay_cycles(19400); TA1R=0X000; break; case 1: TA1CCR1 = 1125; __delay_cycles(18875); break; case 2: TA1CCR1 = 1650; __delay_cycles(18350); break; case 3: TA1CCR1 = 2175; __delay_cycles(17825); break; case 4: TA1CCR1 = 2700; __delay_cycles(17300); break; } }