cancel
Showing results for 
Search instead for 
Did you mean: 

Unable to read data from L6470 Motor Driver

Ibrahimsha
Associate II

I m using STM32L552ZE as SPI Master and slave device is L6470 stepper driver. Write operation everything is fine. While i tried to read the data from STATUS Register (0x19) or GETSTATUS register(0xD0). I received only floating values not a constant one. So i had doubt about read sequence.

This is my code.

uint32_t SPI_GetStatus(uint8_t command)
{
static uint8_t TramsmitData[4];
TramsmitData[0] = command;
TramsmitData[1] = 0x00;
TramsmitData[2] = 0x00;
TramsmitData[3] = 0x00;

static uint8_t receivedData[4] = {0};

for (int index = 0; index < 3; index++)
{
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1,&TramsmitData[index], sizeof(TramsmitData[index]), HAL_MAX_DELAY);
HAL_SPI_Receive(&hspi1, &receivedData[index],sizeof(receivedData[index]), HAL_MAX_DELAY);
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_4, GPIO_PIN_SET);
}

DebugLog("receivedData[0] %d \r\n",receivedData[0]);
DebugLog("receivedData[1] %d \r\n",receivedData[1]);
DebugLog("receivedData[2] %d \r\n",receivedData[2]);
DebugLog("receivedData[3] %d \r\n",receivedData[3]);
}

2 REPLIES 2
Cristiana SCARAMEL
ST Employee

Hello @Ibrahimsha and welcome to the ST Community.

I suggest to check the SPI configuration (CPOL and CPHA).

You must set CPOL = 1 and CPHA = 1 (the IC updates the out on the falling edge and samples on the rising edge).

Concerning to the communication protocol you can refer also to application notes AN4290 for more details.

Let me know if this solve your problem, if yes please accept it by clicking on "Accept as solution".

Ibrahimsha
Associate II

Thank you!