AnsweredAssumed Answered

Write issues with CTRL_REG6_XL of LSM6DS0

Question asked by thy on Jan 11, 2016
Hi everybody,

I have a custom board hosting an LSM6DS0 sensor and an STM32F427 micro which communicate via SPI. The SPI interface is configured as follow:
01.SPI5h.Instance               = SPI_MEMS;
02.SPI5h.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_16; /* 5 MHz */
03.SPI5h.Init.Direction         = SPI_DIRECTION_2LINES;
04.SPI5h.Init.CLKPhase          = SPI_PHASE_2EDGE;
05.SPI5h.Init.CLKPolarity       = SPI_POLARITY_HIGH;
06.SPI5h.Init.CRCCalculation    = SPI_CRCCALCULATION_DISABLE;
07.SPI5h.Init.CRCPolynomial     = 7;
08.SPI5h.Init.DataSize          = SPI_DATASIZE_8BIT;
09.SPI5h.Init.FirstBit          = SPI_FIRSTBIT_MSB;
10.SPI5h.Init.NSS               = SPI_NSS_HARD_OUTPUT;
11.SPI5h.Init.TIMode            = SPI_TIMODE_DISABLE;
12.SPI5h.Init.Mode              = SPI_MODE_MASTER;

At startup I firstly check if the module is present reading successfully the WHO_AM_I register, then I try to configure the CTRL_REG6_XL register to enable the accelerometer. So I perform the following write/read operations
1.HAL_SPI_Transmit(&SPI5h, &wCTRL_REG6_XL, sizeof(rCTRL_REG6_XL), 1000);
2.HAL_SPI_Transmit(&SPI5h, &diCTRL_REG6_XL, sizeof(diCTRL_REG6_XL), 1000);
3.HAL_Delay(100);
4. 
5.HAL_SPI_Transmit(&SPI5h, &rCTRL_REG6_XL, sizeof(rCTRL_REG6_XL), 1000);
6.HAL_SPI_Receive(&SPI5h, &rxSENSOR, sizeof(rxSENSOR), 1000);
7.HAL_Delay(100);

where wCTRL_REG6_X = 0x20, rCTRL_REG6_X = wCTRL_REG6_X | 0x80 and diCTRL_REG6_XL = 0x20 is the configuration data. That is, I just switch on the accelerometer leaving every other parameter at default.

At row 5, then I read again the register content to check whether the settings have been correctly stored, but rxSENSOR = 0xF0. Within the module's reference pdf I could not find anything related with this and I am really puzzled.

Any suggstion is appreciated.

Regards.

Outcomes