AnsweredAssumed Answered

STM32F405 + ADIS16485 IMU, SPI troubles

Question asked by Vinci on Apr 16, 2014
Hello forum

I've just signed up here since I ran into troubles reading sensor data from an Analog Devices IMU with SPI. I'm still a beginner with the Cortex M4, so maybe I'm missing something crucial... but the problem is kinda weird.

First here's the datasheet for the IMU:
http://www.analog.com/static/imported-files/data_sheets/ADIS16485.pdf

I've set up my board according to the datasheet and use SPI2 in 16bit full-duplex mode, MSB first, with CPOL high, CPHA 2nd edge and a baudrate of 5.25MBits/s. So far so good. I set the flash memory of the IMU to page0 in order to access the registers which hold the sensor data and then start requesting the 24 16bit data registers I would like to read in an infinite loop. This works well for some unknown time and then all of a sudden I can only read crap... It makes no difference if I try to read the data with polling or interrupt based, the outcome is always the same.

The register addresses defined in my code can be found in the datasheet. For test purposes only I set the 12th entry of my transmit buffer to request the product ID which should always return "16485".

Any ideas?
spi_TxBuffer[0] = W_PAGE_ID0;
 
HAL_SPI_Transmit(&hspi2, (uint8_t *)spi_TxBuffer, BUFFERSIZE, TIMEOUT);
 
spi_TxBuffer[0]  = R_X_GYRO_LOW;
spi_TxBuffer[1]  = R_X_GYRO_OUT;
spi_TxBuffer[2]  = R_Y_GYRO_LOW;
spi_TxBuffer[3]  = R_Y_GYRO_OUT;
spi_TxBuffer[4]  = R_Z_GYRO_LOW;
spi_TxBuffer[5]  = R_Z_GYRO_OUT;
spi_TxBuffer[6]  = R_X_ACCL_LOW;
spi_TxBuffer[7]  = R_X_ACCL_OUT;
spi_TxBuffer[8]  = R_Y_ACCL_LOW;
spi_TxBuffer[9]  = R_Y_ACCL_OUT;
spi_TxBuffer[10] = R_Z_ACCL_LOW;
spi_TxBuffer[11] = R_Z_ACCL_OUT;
spi_TxBuffer[12] = R_PROD_ID;
spi_TxBuffer[13] = R_X_DELTANG_OUT;
spi_TxBuffer[14] = R_Y_DELTANG_LOW;
spi_TxBuffer[15] = R_Y_DELTANG_OUT;
spi_TxBuffer[16] = R_Z_DELTANG_LOW;
spi_TxBuffer[17] = R_Z_DELTANG_OUT;
spi_TxBuffer[18] = R_X_DELTVEL_LOW;
spi_TxBuffer[19] = R_X_DELTVEL_OUT;
spi_TxBuffer[20] = R_Y_DELTVEL_LOW;
spi_TxBuffer[21] = R_Y_DELTVEL_OUT;
spi_TxBuffer[22] = R_Z_DELTVEL_LOW;
spi_TxBuffer[23] = R_Z_DELTVEL_OUT;
 
/* Infinite loop */
while (1)
{  HAL_Delay(200);
  HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_15);
 
  HAL_SPI_TransmitReceive_IT(&hspi2, (uint8_t *)spi_TxBuffer, (uint8_t *)spi_RxBuffer, BUFFERSIZE);
  //HAL_SPI_TransmitReceive(&hspi2, (uint8_t *)spi_TxBuffer, (uint8_t *)spi_RxBuffer, BUFFERSIZE, TIMEOUT);
 
}


/edit
I begin to start thinking that there needs to be a certain delay between register request to the IMU or something... the there is nothing mentioned in the datasheet.

/edit2
Alright. I just solved the problem by manually switching CS...
I though that's what NSS hardware management is supposed to be for, but apparently it's not.

Outcomes