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

DRV8711EVM: TMS320F280025C Communication Problem

$
0
0
Part Number: DRV8711EVM
Other Parts Discussed in Thread: DRV8711, TMS320F280025C

Tool/software:

Dear Support Team,

I am working on controlling a step motor using the DRV8711 EVM board. To test whether the board has any hardware issues, I first used an Arduino UNO and obtained the following logic analyzer signal. With this setup, I was able to control the motor as desired.

Arduino Uno Logic Capture

DRV8711 Writing Timing Diagram

As the next step, I am attempting to control the same motor with the same DRV8711 EVM board using the TMS320F280025C LAUNCHXL. Below is the SPI write timing diagram from the DRV8711 datasheet, which I used as a reference for my initialization. My initialization code is as follows: (SPI Baud Rate 1 MHz for SPI_BIT_RATE 24)

void spi_init(void)
{
EALLOW;

GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 3;
GpioCtrlRegs.GPAGMUX1.bit.GPIO8 = 1;

GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 3;
GpioCtrlRegs.GPAGMUX1.bit.GPIO9 = 1;

GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 3;
GpioCtrlRegs.GPAGMUX1.bit.GPIO10 = 1;

GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 0;
GpioCtrlRegs.GPAGMUX2.bit.GPIO23 = 0;

GpioCtrlRegs.GPAPUD.bit.GPIO23 = 1;
GpioCtrlRegs.GPAINV.bit.GPIO23 = 0;
GpioCtrlRegs.GPAODR.bit.GPIO23 = 0;
GpioCtrlRegs.GPAQSEL2.bit.GPIO23 = 0;
GpioCtrlRegs.GPADIR.bit.GPIO23 = 1;

GpioCtrlRegs.GPAQSEL1.bit.GPIO8 = 3; // Asynch input (SPISIMOA)
GpioCtrlRegs.GPAQSEL1.bit.GPIO10 = 3; // Asynch input (SPISOMIA)
GpioCtrlRegs.GPAQSEL1.bit.GPIO9 = 3; // Asynch input (SPICLKA)

EDIS;

SpiaRegs.SPICCR.bit.SPISWRESET = 0;
SpiaRegs.SPICCR.bit.CLKPOLARITY = 0;
SpiaRegs.SPICCR.bit.SPICHAR = (8 - 1);
SpiaRegs.SPICCR.bit.SPILBK = 0;

SpiaRegs.SPICTL.bit.MASTER_SLAVE = 1;
SpiaRegs.SPICTL.bit.TALK = 0;
SpiaRegs.SPICTL.bit.CLK_PHASE = 1;
SpiaRegs.SPICTL.bit.SPIINTENA = 0;

SpiaRegs.SPIPRI.bit.TRIWIRE = 0;

SpiaRegs.SPIBRR.bit.SPI_BIT_RATE = 24;
SpiaRegs.SPIPRI.bit.FREE = 1;

SpiaRegs.SPICCR.bit.SPISWRESET = 1;

SpiaRegs.SPIFFTX.bit.TXFIFO=1;
SpiaRegs.SPIFFTX.bit.SPIRST = 1;
SpiaRegs.SPIFFTX.bit.SPIFFENA = 1;
SpiaRegs.SPIFFRX.bit.RXFIFORESET=1;
}

This initialization is designed to comply with the datasheet instruction: "To complete the read or write transaction, SCS must be set to a logic 0." My transmit function is as follows:

Uint16 spi_txmit(Uint16 data)
{
int ret = SPI_SUCCESS;
Uint16 datain = 0;

SpiaRegs.SPIFFTX.bit.TXFIFO = 1;

if(ret)
{
Uint16 timeout = 1000;
if(SpiaRegs.SPIFFRX.bit.RXFFST)
{
datain = SpiaRegs.SPIRXBUF;
}

while(SpiaRegs.SPISTS.bit.BUFFULL_FLAG != 0 && timeout)
--timeout;

if(!timeout)
ret = SPI_FAILURE;

if(ret)
{
timeout = 1000;

while (SpiaRegs.SPIFFTX.bit.TXFFST != 0);

SpiaRegs.SPITXBUF = (SpiaRegs.SPICCR.bit.SPICHAR < 8) ? ((data << 8) & 0xFF00) : data;

SpiaRegs.SPICTL.bit.TALK = 1;

while(!SpiaRegs.SPIFFRX.bit.RXFFST && timeout)
--timeout;

if(!timeout)
ret = SPI_FAILURE;

if(ret){
SpiaRegs.SPICTL.bit.TALK = 0;
}
}

}
return ret == SPI_SUCCESS ? (int)(datain & 0xFF) : ret;
}

void drv8711_transmit(uint8_t address, uint16_t data)
{
uint8_t data_high_byte = ((data >> 8) & 0x1F) | ((address & 0x07) << 5);

uint8_t data_low_byte = data & 0xFF;
spi_chipselect(1);

spi_txmit(data_high_byte);
spi_txmit(data_low_byte);

DELAY_US(2);

spi_chipselect(0);
}

Despite this setup, the logic analyzer sample I obtained after executing the code shows that the step motor is not functioning. Below is the signal I captured:

F28002x CPOL 1 Logic Capture

Currently, CPOL is set to 0, and CPHASE is set to 1. However, the data I observe on the logic analyzer is incorrect; instead of seeing the expected data (0x03 and 0x31), I am seeing 0x07 and 0x63. My logic analyzer settings are CPOL 0, CPHASE 1, with the enable line set as Active High. When I change CPHASE to 0 on the logic analyzer, I get the following signal: the data appears correct, but the signal is not as expected.

F28002x CPOL 0 Logic Capture 

The main difference between the signals generated by Arduino and TMS320 is the time between two clock cycles: 1.875 µs for Arduino and 3.5 µs for TMS. As noted in my code, there is no intentional delay between transmissions. Additionally, to keep the MOSI line HIGH during transmission, I enable the TALK bit on the TMS during data transmission and disable it once the FIFO is empty.

The F28002x Technical Reference Manual describes the data transmission process as follows, but this behavior conflicts with the DRV8711's requirements, so I made the adjustments in my code accordingly:

F28002x Writing Timing Diagram

At this point, I am unsure if my SPI implementation is correct, and I am stuck in controlling the step motor. Could you please help me resolve this issue?

Thank you in advance for your support.

Best regards,


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>