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.

DRV10983 i2c communication with msp430g2553

Other Parts Discussed in Thread: MSP430G2553, DRV10983, DRV10983EVM, DRV10983EVM-TB

Hello, i am trying to read a register of drv10983 from msp430g2553 but it is not working ,so please

let me know where i am going wrong.                        

here is my code :


P1SEL |= BIT6 + BIT7; // Assign I2C pins to USCI_B0
P1SEL2|= BIT6 + BIT7; // Assign I2C pins to USCI_B0

UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0CTL0 = UCMST + UCMODE_3 + UCSYNC; // I2C Master, synchronous mode
UCB0CTL1 = UCSSEL_2 + UCSWRST; // Use SMCLK, keep SW reset
UCB0BR0 = 24; //SMCLK/24 = 50 kHz
UCB0BR1 = 0;
UCB0I2CSA = DRV10983; // Slave Address is 0x52
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation
// IE2 |= UCB0RXIE + UCB0TXIE; // Enable TX interrupt

//SALVE ID
while (UCB0CTL1 & UCTXSTP) {;} // Ensure stop condition got sent
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition

while (UCB0CTL1 & UCTXSTT) {;} //wait for transmission to finish

// REFRESH eeprom
//ADDRESS
UCB0TXBUF = 0x03;

while(!(UCB0TXIFG)) {;}

//DATA
UCB0TXBUF = 0x20;

while(!(UCB0TXIFG)) {;}


UCB0CTL1 |= UCTXSTP; // I2C stop condition
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent

UCB0CTL1 |= UCSWRST; // Enable SW reset

UCB0I2CSA = DRV10983; // Slave Address is 0x52h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation

//READ REGISTER
//SALVE ID
UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start condition
while (UCB0CTL1 & UCTXSTT) {; } //wait for transmission to finish // Load TX buffer

//read register ADDRESS
UCB0TXBUF = 0X10;
while(!(UCB0TXIFG)) {;}

//I2C STOP
UCB0CTL1 |= UCTXSTP; // I2C stop condition
while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent

UCB0CTL1 |= UCSWRST; // Enable SW reset
UCB0I2CSA = DRV10983; // Slave Address is 048h
UCB0CTL1 &= ~UCSWRST; // Clear SW reset, resume operation

//READ REGISTER
//SALVE ID
//UCB0CTL1 |= UCTR + UCTXSTT; // I2C TX, start conditionUCB0CTL1 &= ~UCTR; // I2C Rx

UCB0CTL1 |= UCTXSTT + UCTXNACK; // I2C start condition

while (UCB0CTL1 & UCTXSTT) {; } //wait for transmission to finish
RX_DATA = UCB0RXBUF;

while(!(UCB0RXIFG)) {;}

UCB0CTL1 |= UCTXSTP; // I2C stop condition

UARTSendChar(RX_DATA);

for(t=0;t<=100;t++);  //small delay


while (UCB0CTL1 & UCTXSTP); // Ensure stop condition got sent

for(t=0;t<=50;t++);   // small delay

  • Hi Vijay,

    Our experts have been notified and should respond in the next few days.

    While waiting, can you provide a little more information?

    What hardware are you using? Is this the DRV10983EVM, DRV10983EVM-TB, or your own board?

    Can you provide a scope capture of the signals from the MSP430G2553 to the DRV10983?

  • Hi Vijay,

    There is an example code on line
    www.ti.com/.../drv10983evm-tb

    Is the example code working for you?

    Thanks,
    Seil
  • Hello, i am using my own designed board with 4.7k pull-up connected on both i2c pins.I have tried to use suggested code but not working. Please let me know whats wrong with that . Here is my code.

    void main(void)
    {
    WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer

    unsigned int i;
    unsigned int vcc=0;

    DCOCTL = 0; // Select lowest DCOx and MODx settings
    BCSCTL1 = CALBC1_1MHZ; // Set DCO
    DCOCTL = CALDCO_1MHZ;
    P1DIR |= BIT6 + BIT7;

    /* while(vcc<0xBB) //wait for VCC to be 22V   //Here code gets hang even if voltage build up 24 v, so i                                                                                              //  comment it and run the microcontroller after voltage gets                                                                                        //  build up for driver ic

    {
    //begin read command for 0x1A
    Start();
    WriteByte(0xA4);
    WriteByte(0x1A);
    Stop();

    //read 0x1A
    Start();
    WriteByte(0xA5);
    P1OUT &=~BIT6;
    P1REN &=~BIT6;
    //DIR_IN;

    //read register with Nack
    vcc=ReadByte();
    Acknowledge();
    Stop();
    }*/

    //set Sidata bit to 1

    Start();
    WriteByte(0xA4);
    WriteByte(0x03);
    WriteByte(0x40);
    Stop();


    for(i=0; i<1; i++)
    {
    //write each register 0x20 to 0x2B
    Start();
    WriteByte(0xA4);
    WriteByte(0x20);
    WriteByte(0x5E);
    Stop();
    }

    //enter the program key
    Start();
    WriteByte(0xA4);
    WriteByte(0x02);
    WriteByte(0xB6);
    Stop();

    //set eeWrite to 1
    Start();
    WriteByte(0xA4);
    WriteByte(0x03);
    WriteByte(0x50);
    Stop();

    //delay to allow eeWrite to finish
    for(i=0;i<20000;i++)

    {
    Delay(10000);                   This delay function is not working so use another simple way to put delay
    }

    //set eeRefresh bit
    Start();
    WriteByte(0xA4);

    WriteByte(0x03);
    WriteByte(0x20);
    Stop();

    while(1)
    {
    for(i=0;i<4;i++)
    {
    //begin the read command for each register
    Start();
    WriteByte(0xA4);
    WriteByte(0x19+i);
    Stop();

    //send the read command for each register
    Start();
    WriteByte(0xA5);
    P1OUT &=~BIT6;
    P1REN &=~BIT6;
    //DIR_IN;

    ///read register with Nack
    r_result_all[i]=ReadByte();
    Acknowledge();
    Stop();

    //compare each register value read to the write
    //register 8 bit 0 can be 0 or 1 so shift right to compare
    if(r_result_all[i] == write_data_all[i])
    end_result &= 1;
    else if(r_result_all[8]>>1 == write_data_all[8]>>1)
    end_result &= 1;
    else
    end_result=0;


    }

    This code works without getting stuck anywhere. I am reading registers from 0x19 to 0x23 and all values are getting zero. Note that i have already written some values in all register. 

  • Hi Vijay,

    Have you used a scope to examine the transactions to and from the DRV10983?

    Are the msp430 pins configured properly? Can you provide the full code, including configuration settings?

    Can you provide a schematic of your board, including the connection to the micro pins?

    The code provided for the DRV10983EVM-TB uses software to create an i2c transaction. If using the hardware i2c, the code should be modified.

  • 
    
    Hi, here i provided my whole project code. 
    Don't worry about hardware pin configuration, i have tested that ,so there is not any concern about hardware side.
    So i think there must be problem with with code of it. 
    SupplyVoltage(0x1A) is 18v at first time execution(why it is not waiting for 22v) and then keep on showing zero.
    so what i think there is actually no i2c communication happening.
    Please let me know, any problem with code.
    /*=========================================================main.c==========================================*/
    
    #include "main.h"
    
    /*
     * main.c
     */
    void main(void)
    {
    
        WDTCTL = WDTPW | WDTHOLD;	 // Stop watchdog timer
    
        unsigned int myvar=0;
        unsigned int speed=0, error_code=0, kt=0, supply=0, TOT_INT=0;
        float float_temp;
    
        BCSCTL1 = CALBC1_1MHZ; 	 	 // set up the clocks
        DCOCTL = CALDCO_1MHZ;
        usartInit();
        i2c_init();
    
        UARTSendArray("SMART_ATOM_FAN\n",15);
        drv_init();				//wait for VCC to be 22V
        while(1)
        {
        	for(myvar=1;myvar<=5;myvar++)
        	{
        		DRV10983_Tx_closeloop();
        		Delay(5000);
        		UARTSendArray("\ntxdone = ",9);
        	}
    
        	Delay(5000);
        	DRV10983_Rx();
        	Delay(5000);
    
        	speed = (DRV10983_register[0x11] << 8) + DRV10983_register[0x12] ;
        	UARTSendArray("\nspeed = ",9);
        	send_number(speed);
    
    		kt = (DRV10983_register[0x15] << 8) + DRV10983_register[0x16];
    		float_temp = kt;
    		float_temp = float_temp *1000 / (2*1090);
    		kt = float_temp;
    		UARTSendArray("\nkt = ",6);
    		send_number(kt);
    
    		supply = DRV10983_register[0x1A];
    		UARTSendArray("\nsupply = ",10);
    		send_number(supply);
    		supply = supply * 300 / 256;
    		UARTSendArray("\nsupply = ",10);
    		send_number(supply);
    
    		error_code=DRV10983_register[0x1E];
    
    		if((error_code & 0x01) == 0x01)
    		{	UARTSendArray("\nlock detection current limit",29);
    			TOT_INT++;
    		}
    		if((error_code & 0x02) == 0x02)
    		{	UARTSendArray("\nspeed abnormal",15);
    			TOT_INT++;
    		}
    		if((error_code & 0x04) == 0x04)
    		{	UARTSendArray("\nkt abnormal",12);
    			TOT_INT++;
    		}
    		if((error_code & 0x08) == 0x08)
    		{	UARTSendArray("\nno motor",9);
    			TOT_INT++;
    		}
    		if((error_code & 0x10) == 0x10)
    		{	UARTSendArray("\nstuck in open loop",19);
    			TOT_INT++;
    		}
    		if((error_code & 0x20) == 0x20)
    		{	UARTSendArray("\nstuck in close loop",20);
    			TOT_INT++;
    		}
    		UARTSendArray("\ntotal int",10);
    		send_number(TOT_INT);
    		UARTSendArray("\n\n",2);
    
    		Delay(5000);
    
        }
    }
    
    
    /*=========================================main.h=====================================================*/
    
    /*
     * main.h
     *
     *  Created on: Jul 13, 2015
     *      Author: USER
     */
    
    #ifndef MAIN_H_
    #define MAIN_H_
    
    #include <msp430.h>
    #include "msp430g2553.h"
    #include "i2c.h"
    #include "DRV10983.h"
    
    #endif /* MAIN_H_ */
    
    
  • Vijay,

    Please refer to the code under software section at this link. http://www.ti.com/tool/drv10983evm

    Please modify the hardware pins according to your hardware connections and that should work.

    Jasraj

  • Vijay ,
    I have tried similar approach for a different hardware and worked for me.
    If still not working, hardware needs to be re looked at.
    Do you recieve an acknowledgement after the Slave address is intiated by master ?
    Jasraj
  • Thank you for your valuable response

    This code is working.

    Motor speed cmd was not given thus motor was not running .So i include that part and now it is working.
    Thank you.

  • Thank you for the update, Vijay.Jasraj