Quantcast
Channel: Motor drivers forum - Recent Threads
Viewing all articles
Browse latest Browse all 14309

DRV8711: DRV8711 Stepper Drive Reg Read Issue

$
0
0
Part Number: DRV8711
Other Parts Discussed in Thread: TM4C1294NCPDT

Hi,

I'm currently having problems reading from my DRV8711 stepper driver ic. The write sequence seem to work fine since my application. I'm now trying to read the registers from the driver, i am not able to read the data from DRV8711 Register at 1st attempt. every time i able to read data at 5th attempt only.

/***************************SPI_Initialize****************************/

void SPI_Initialize (void)

{


// The SSI0 peripheral must be enabled for use.

SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI2);

SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);

GPIOPinConfigure(GPIO_PD3_SSI2CLK);

//GPIOPinConfigure(GPIO_PD2_SSI2FSS);

GPIOPinConfigure(GPIO_PD1_SSI2XDAT0);

GPIOPinConfigure(GPIO_PD0_SSI2XDAT1);

GPIOPinTypeSSI(GPIO_PORTD_BASE,GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_3);

SSIConfigSetExpClk(SSI2_BASE, g_ui32SysClkFreq, SSI_FRF_MOTO_MODE_0,SSI_MODE_MASTER,1000000,8);

SSIEnable(SSI2_BASE);

}


/***************************SPI_DRV8711_Write_Sequnece****************************/

void SPI_DRV8711_Write(unsigned char dataHi, unsigned char dataLo)

{

unsigned int data;

g_Write_Data01[0] = dataHi;

g_Write_Data01[1] = dataLo;
SPI_Motor_CS_High;

SSIDataPut(SSI2_BASE, dataHi);

while(SSIBusy(SSI2_BASE));

SSIDataPut(SSI2_BASE, dataLo);

while(SSIBusy(SSI2_BASE));

SPI_Motor_CS_Low;


/***************************SPI_DRV8711_Read_Sequnece****************************/

unsigned int SPI_DRV8711_Read(unsigned char dataHi, unsigned char dataLo)


{

SPI_Motor_CS_High;

SSIDataPut(SSI2_BASE, dataHi);

while(SSIBusy(SSI2_BASE));

SSIDataGet(SSI2_BASE, &RxdataHi);

SSIDataPut(SSI2_BASE, dataLo);

while(SSIBusy(SSI2_BASE));

SSIDataGet(SSI2_BASE, &RxdataLo);

g_Read_Data01[0] = 0x80 ^ RxdataLo;
g_Read_Data01[1] = RxdataHi;

SPI_Motor_CS_Low;

}


/***************************Motor_PowerUp_Reset_Sequnece****************************/

void Motor_Powerup_Reset_Sequnece(void)

{

SleepMode_Input_Low;

Reset_Input_High;

SysCtlDelay(10000000);

SysCtlDelay(10000000);

SysCtlDelay(10000000);

SysCtlDelay(10000000);

Reset_Input_Low;

SleepMode_Input_High;

SysCtlDelay(10000000);

SysCtlDelay(10000000);

SleepMode_Input_Low;
}


/***************************Motor_Current_Write_Sequnece****************************/

void Motor_Current_WriteSequenece(void)

{


unsigned char dataHi = 0x00;

unsigned char dataLo = 0x00;


/
dataHi = RegWrite | (Motor_Torque_Register.Address << 4) | (Motor_Torque_Register.SIMPLTH);

dataLo = Motor_Torque_Register.TORQUE;
SPI_DRV8711_Write(dataHi,dataLo);

}


}


/***************************Main Program****************************/

volatile uint8_t Write=0;

volatile uint8_t Read_90=0;

volatile uint8_t Current=0X32;

void main(void)

{


SPI_Initialize();

Motor_Powerup_Reset_Sequnece();


while(1)

{


if(Write==1)

{
 
Motor_Torque_Register.TORQUE = Current;
 
Motor_Current_WriteSequenece();
 
Write = 0;

}

if(Read_90==1)

{

SPI_DRV8711_Read(0x90,0x00);

Read_90 = 0;

}


}

Master MCU - TM4C1294NCPDT

Slave 1 to 4  - DRV8711


Viewing all articles
Browse latest Browse all 14309

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>