Unable to read data from L6470 Motor Driver
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]);
}
