This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DRV8313 EVM Timer Register change

Other Parts Discussed in Thread: DRV8313EVM, MSP430G2553, DRV8313

Hi,

In DRV8313EVM_RevB   using T0.1 for PWM generation so i have changed the timer register in Hardware_Config.c ,and port configuration,however motor is not spinning ,Is there any other changes need to be done.Am attaching the code ,

I have changed the Timer register in main.c(Init_Timer function) and hardware_config.c and also ports

Kindly suggest is there any mistake or need to change any other settings.

0045.r15382v1.pdf

/*
 * Main.c
 *
 *  Created on: Aug 7, 2013
 *      Author: a0131604
 */


#include "msp430g2553.h"
#include "INSTA_SPIN.h"

void setupUART115200();
void Init_Clocks ();
void Init_Timer ();
void Init_IOs (void);
void Init_ADC ();
void All_Reset_ON(void);
void Process_UART_Data ();
void Init_System_Variables ();
void mode_initialize();

#define CONVERSION_ENABLE        \
		ADC10CTL0 |= ENC;





void main()
{

	WDTCTL = WDTPW + WDTHOLD;				// Stop watch-dog timer to prevent time out reset
	_delay_cycles (5000);
	Init_Clocks ();
	Init_IOs ();
	Init_Timer ();

#ifdef GUI
	setupUART115200();
#endif

	Init_ADC ();
	Init_System_Variables ();
	mode_initialize();
	CONVERSION_ENABLE;
 	__bis_SR_register(GIE);                   // LPM0, ADC10_ISR will force exit


 	Init_InstaSpin();


	while(1)
	{
		InstaSpin();

#ifdef GUI
		Process_UART_Data ();
#endif

	}

}



void Init_ADC ()
{
	ADC10CTL0 |= SREF_1 + ADC10SHT_2 + ADC10ON + ADC10IE + REFON + REF2_5V;
	ADC10CTL1 = INCH_6 + CONSEQ_0 + ADC10SSEL_2 ;			// Sequence of channels upto A6
	ADC10AE0  |= 0x40;
}



void Init_IOs (void)
{
	// setup for PWMC
	P3DIR |= BIT1+BIT2+BIT0+BIT7;				//P3.0 to P3.5 as Outputs

	P1DIR |= BIT2;
        P2DIR |= BIT6;
	P3DIR |= BIT5;
	//PWM_A
	P1SEL |= BIT2;
	P1SEL2 &= ~BIT2;

	//PWM_B
        P3SEL |= BIT5;
        P3SEL2 &= ~BIT5;

	//PWM_C
	P2SEL |= BIT6;
	P2SEL &= ~BIT7;
	P2SEL2 &= ~(BIT6+BIT7);

	//P2DIR |= BIT7;
	P3OUT &= ~(BIT4+BIT7);
	//P3DIR |= BIT7;
}



void Init_Timer (void)
{
	/*TA1CCR0	= 400;							// Load the Reference Count
	TA1CCTL2	= OUTMOD_6;
	TA1CCR2		= (100-START_UP_DUTY) * 4;
	TA1CTL		= TASSEL_2 + MC_3 + TACLR ;		//+ TAIE;	//Up-Down Mode , SMCLK , Timer Clear*/

	TACCR0		= 400;							// Load the Reference Count
	TACCTL0		= CCIE;
	TA0CCR1		= (100-START_UP_DUTY) * 4; // Load the Reference Count
	TA0CCTL1	= OUTMOD_6;
	TACCTL2	= OUTMOD_6;
	TACCR2		= 398;
	TACTL		= TASSEL_2 + MC_3 + TACLR ;		//+ TAIE;	//Up-Down Mode , SMCLK , Timer Clear


	WDTCTL 		= WDT_MDLY_32;
	IE1 		|= WDTIE;                         // enable WDT interrupt
	_EINT();                              // Enable interrupts
}



void setupUART115200(void)
{
	//Setup USCI to UART on P1.1 and P1.2
	P1SEL = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD
	P1SEL2 = BIT1 + BIT2 ;                     // P1.1 = RXD, P1.2=TXD
	UCA0CTL1 |= UCSSEL_2;                     // SMCLK
	UCA0BR0 =138;                            // 16MHz 115200
	UCA0BR1 = 0;                              // 16MHz 115200
	UCA0MCTL = UCBRS_7;                        // Modulation UCBRSx = 1
	UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**
	IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt
}



void Init_Clocks (void)
{
	BCSCTL1		= CALBC1_16MHZ;               	// Set DCO ~ 16 Mhz
	DCOCTL		= CALDCO_16MHZ;
	BCSCTL1 	|= DIVA_1;                    	// ACLK/(0:1,1:2,2:4,3:8)
	BCSCTL3 	|= LFXT1S_2;                  	// LFXT1 = VLO
}



void All_Reset_ON(void)
{
	P3OUT |= (BIT0+BIT1+BIT2);
}



#pragma vector=TIMER0_A0_VECTOR
__interrupt void Timer_A0 (void)
{
	Measure_Speed++;

}

/*
 * hardware_config.c
 *
 *  Created on: Aug 7, 2013
 *      Author: a0131604
 */

#include "msp430g2553.h"

/***********************************************************************************************************************/
// NOTE : do not change the name of the functions or their return types , as they are called from the library functions
/***********************************************************************************************************************/

unsigned int PWM_REGISTER_READ()
{
	return ( TACCR1 ) ;                                            //  if a different timer register  is used, change the return value to the new timer register
}

volatile unsigned int * PWM_INITIALIZER ()
{
	return ( & TACCR1 );                                          // the return value should be the address of the timer register used
}


void MAKE_COPY()
{
	return;                                                      // should be used only when more than one timers are used .
																 // to copy the value of one timer register to another ,  include the copying procedure here
}

void DRV_RESET_ENABLE()
{
	 P3OUT &= ~(BIT4+BIT7);                                      // to put drv8313 to reset and in sleep mode
}



void DRV_RESET_DISABLE()
{
	P3OUT |= (BIT4);											// to bring drv8313 out of reset
}

void DRV_SLEEP_DISABLE()
{
	P3OUT |= (BIT7);											// to bring drv8313 out of sleep mode
}


unsigned char  FAULT_STATE_PIN_FUNCTION()
{
	return(P3IN & 0x40 ) ;                                      // take the input from the drv8313 to check for faults
}

// for the below functions ,  the function name indicate the procedure to be initiated to do the corresponding action

void A_HIGH ()
{
						P1OUT |= BIT2;
						P3OUT |= BIT0;
}

void A_PWM	()
{
	P1SEL |= BIT2;

    P3OUT |= BIT0;

}

void A_LOW	()
{
						P1SEL &= ~BIT2;
						P1OUT &= ~BIT2;
						P3OUT |= BIT0;
}

void A_Z()
{
	                        P1SEL &= ~BIT2;
							P1OUT &= ~BIT2;
						    P3OUT &= ~BIT0;
}

void B_HIGH ()
{
						P3OUT |= BIT5;
						P3OUT |= BIT1;
}


void B_PWM 	()
{
P3SEL |= BIT5;

P3OUT |= BIT1;
}


void B_LOW 	()
{


						P3SEL &= ~BIT5;
						P3OUT &= ~BIT5;
						P3OUT |= BIT1;
}


void B_Z	()
{
						P3SEL &= ~BIT5;
						P2OUT &= ~BIT5;
						P3OUT &= ~BIT1;
}


void C_HIGH	()
{
						P2OUT |= BIT6;
						P3OUT |=BIT2;
}


void C_PWM	()
{
	P2SEL |= BIT6;
  P3OUT |=BIT2;
}


void C_LOW 	()
{
						P2SEL &= ~BIT6;
						P2OUT &= ~BIT6;
						P3OUT |= BIT2;
}


void C_Z 	()
{
						P2SEL &= ~BIT6;
						P2OUT &= ~BIT6;
						P3OUT &= ~BIT2;
}



Thank you in advance