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

3225.Main.c
/*
 * 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++;

}

8015.Hardware_Config.c
/*
 * 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

  • Hi Shruthi,

    There appears to be a typo in the B_Z modifications. Can you confirm that

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

    Also with the new configuration, how you communicate through the GUI? It appears if you are using the GUI, you may not be able to configure or start.

  • Yeah Sir it is P3OUT &= ~BIT5; thank you but still it is not working

    Am running it in stand alone mode,and it is working properly in stand alone mode with TI Code(without modified).

  • Shurthi,

    You also need to change the DRV8313 IN1/2/3 inputs to TA0.1 output pins of MSP430G2553,  I'm not having MSP430G2553 data-sheet at moment, but I'm sure that it is not available 14/17 and 18.

    By the way, What is your exact purpose to change the PWM to TA0.1 from TA1.2 ? 

    Best Regards

    Milan-Motor Application Team

  • yeah Sir i have modified the PCB in such a way that it works with both TI source code and also modified(timer register) Pl have a look at the schematic.

    for IN1/2/3 am using pins 4,19,27 of MSP430G2553 TA0.1and Am not using it in GUI mode.

    I am freeing up one timer so that i can4265.r15382v1pcb.pdf3286.msp430g2553.pdf use the other timer for remote control.

  • Hi Shruthi,

    Are the timer outputs at the new locations matching the timer outputs of the TI source code?

    If not, is it possible to create code that runs both TA0.1 and TA1.2 in parallel?  This would allow debugging of your new timers with the TI code running in parallel.

    Once it matches you can switch to the new ports and everything should work. The TI timer configuration can be then commented out.

  • Hi Sir,

    Are the timer outputs at the new locations matching the timer outputs of the TI source code?

    i tried checking for the timer outs ,no output is coming but DRV8313 is getting heated up.

    If not, is it possible to create code that runs both TA0.1 and TA1.2 in parallel?  

    create a code means do i need to calculate commutation instance of the motor?or there is any way i can check the timer outs?

    Thank you

  • Hi Sir,


    could you Pl tell me whether i can modify the code with just timer change , free up a timer and use it for other function?

    i have changed the timer register and IN1/2/3,  it is not working so can we implement it just modifying the TI source code?

    Thank you

  • Shruthi,

    I think we are goin back and forth on this topic. Let's resolve the issues one by one.  

    Since your board has jumper options for IN1/2/3, let's first connect these 3 inputs as per DRV8313 EVM. Use EVM software to run the motor, in stand-alone or POT mode. Motor should run properly as it runs using EVM, if not there is some issue with your board either in layout or any other un-known issue, we should first fix this before attempting to change the software for timer change.

    Pease let us know if the result if you are able to successfully run the motor after changing the IN1/2/3 inteface as suggested above.

    Best Regards

    Milan-Motor Application Team

  • Yes Sir, it is running perfectly in stand-alone mode using pot with TI source code.

  • Shruthi,

    Please wait for some more time, let me do the same experiment on EVM. I will revert back by early next week.

    Best Regards

    Milan

  • Thank you very much Sir,mean while i will experiment on it .