Controlling 3 motors with MSP430

Hi,

My first post in this forum, and I hope to continue a long time.

This summer I´m learing how to program the MSP430F2274, I find it extremly interesting.

Right now I got a litlle bit stuck on the following project:

I´m trying to control 3 motors at the same time with the msp430. The speed will be regulated with PWM, and the input I will want to control it with 3 potenciometers. One POT for each motor. The way that I´m trying to do that is using de DTC to store 3 samples, one sample of each POT and read it back using ADC10SA pointer. Each value of the POT will be converted directly to the PWM duty cicle.

So, therre is something that will not work, when I hook it up I´ll see a wierd square wave (I think in P2.3), with some strange duty cicle, and it will romain constant even if w vary the POT’s. And in the other 3 PIN´s that should give me some more PWM do not respond.

Could someone please tell me why?

Thank you so much in advance for all your time.

CODE:

#include “msp430x22x4.h”

unsigned int DATA[3];

void main(void){

WDTCTL = WDTPW + WDTHOLD; // Stop WDT

//ADC SETTINGS

ADC10CTL1 = INCH_2 + CONSEQ_1; // A2/A1/A0, single sequence

ADC10CTL0 = ADC10SHT_2 + MSC + ADC10ON + ADC10IE;

ADC10DTC1 = 0x03; //3 Conversions

ADC10AE0 |= 0x07; //Set A2 A1 and A0 as ADC10 inputs

//PWM SETTINGS

P2DIR |= 0x18; //Setting P2.3 and P2.4 as outputs

P2SEL |= 0x18; //Selecting the special function of P2.3 and P2.4 for the PWM

P4DIR |= 0x10; //Setting P4.4 as output

P4SEL |= 0x10; //Selecting the special function of P4.4 for the PWM

TACCR0 |= 1023; //setting duty period of TimerA

TBCCR0 |= 1023; //setting duty period of TimerB

TACCTL1 = OUTMOD_7;

TACCTL2 = OUTMOD_7;

TBCCTL1 = OUTMOD_7;

//Program initialitzation

for(;;){

//Sampling ADC10

ADC10CTL0 &= ~ENC;

while(ADC10CTL1 & BUSY); //Wait if the ADC10 core is active

ADC10SA = (unsigned short)&DATA;

ADC10CTL0 |= ENC + ADC10SC; // Sampling and conversion start

ADC10CTL0 &= ~ENC;

ADC10CTL0 = 0; // Power down the ADC

//Setting PWM

TACTL = TASSEL_2 + MC_1;

TACCR1 = DATA[3];

TACCR2 = DATA[2];

TBCTL = TBSSEL_2 + MC_1;

TBCCR1 = DATA[1];

}

}