i am using msp430fg4618 and drv811 to run a 7.5 degree, 12V stepper motor in microstep mode....assume rpm=120
i have a written a program to give PWM signal of 50% duty cycle to the STEP pin of 8811. is it right?
#include <msp430fg4618.h>
#include <in430.h>
void main(void)
{
volatile unsigned int i;
WDTCTL = WDTPW +WDTHOLD; // Stop WDT
SCFQCTL = 0x82; //f= 2*32768*(4+1) approx
equals 320kHz
SCFI0 = 0x40;
FLL_CTL0 = 0x30; //DCO outputis divided,
Xcap=10pf
FLL_CTL1 = 0x20; //XT2 is OFF, MCLK=SMCLK=DCO
// Wait for xtal to stabilize
do
{
IFG1 &= ~OFIFG; // Clear OSCFault flag
for (i = 0x47FF; i > 0; i--); // Time for flag to set
}
while ((IFG1 & OFIFG)); // OSCFault flag still set?
P1DIR |= 0x04; // P1.2 output
P1SEL |= 0x04; // P1.2 TA1 option
TACCR0 = 3277-1; // PWM Period
TACCTL1 = OUTMOD_7; // TACCR1 reset/set
TACCR1 = 1639; // TACCR1 PWM duty cycle
TACTL = TASSEL_2 + MC_1; // SMCLK, up mode
}
if the above program is right, i just need to configure the rest of the pins as follows?
ENABLE- low
SLEEP- high
USM0,USM1- high (8th microstep)
RESET- high
SRn- high
HOMEn-high
DIR- low