H3LIS331DL
Hi,
I readed the default value of the identification register in H3LIS331DL by SPI mode and it responded with 0x32h as per the data sheet,but while reading the STATUS REG default value it responded with 0xFFh instead of 0x00h. How it's possible one register responding with correct data as per data sheet,but another one with incorrect data and for your reference see my code below.
//Address deceleration.
uint16_t Who_am_i=0x8F00;
uint16_t STATUS_REG=0xA700;
//Variable deceleration.
char Status_Reg;
char Identification;
// Implementation part in While loop
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1,(uint8_t*) &Who_am_i, 1, 1000);
HAL_SPI_Receive(&hspi1, (uint8_t*)&Identification, 1, 1000);
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
uart_buf_len = sprintf(uart_buf,"Identification = 0x%02X\r\n", (unsigned int)Identification);
HAL_UART_Transmit(&huart2, (uint8_t*)uart_buf,uart_buf_len, 100);
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_RESET);
HAL_SPI_Transmit(&hspi1,(uint8_t*) &STATUS_REG, 1, 1000);
HAL_SPI_Receive(&hspi1, (uint8_t*)&Status_Reg, 1, 1000);
HAL_GPIO_WritePin(CS_GPIO_Port, CS_Pin, GPIO_PIN_SET);
uart_buf_len = sprintf(uart_buf,"Status_Reg = 0x%02X\r\n", (unsigned int)Status_Reg);
HAL_UART_Transmit(&huart2, (uint8_t*)uart_buf,uart_buf_len, 100);
output
Identification = 0x32
Status_Reg = 0xFF
Thank you
