2017-12-07 09:00 PM
The original post was too long to process during our migration. Please click on the attachment to read the original post.
Solved! Go to Solution.
2017-12-11 10:30 AM
Oh!! Finally, the problem is solved just by 3 lines of code:
SPI_send(0x25,0x90);
SPI_send(0x23,0x01);
SPI_send(0x20,0x67);
I think 'force reboot'ing solved my problem(first bit of register 0x25). Now it is working even if I comment it out. Strange. Really, I changed nothing else. I have been writing to 0x20 and 0x23 registers but I had not seen anything about 0x25.
2017-12-09 01:39 AM
Are you able to capture the SPI communication usign scope or logic analyzer?
It would be very handy to see what os going on the SPI bus.2017-12-09 10:45 AM
Hi! I tried to see MOSI and MISO signals. There was something on MOSI line, but MISO line was like pulled up high. I think that's why it gives me ones. Could it be some problem of HAL libraries? I can't seem to find HAL version example for LIS3DSH.
2017-12-11 07:20 AM
To solve the problem I recommend to investigate more the SPI communication with scope or logic analyzer. First you must be sure that the microcontroler sends correctly the data, only than the slave (sensor) can reply. You can check the most simple read who_am_i procedure, the sensor must respond to this request. If you will share the communication I can check it.
I suppose the problem is in the SPI configuration or in HW connection.
2017-12-11 08:46 AM
Yes, I also think the problem is in config. I tried exactly the code by Andrei Chichak to read WHO_I_AM register.
void
SPISend
(uint8_t
* transmit,uint8_t
* receive,uint16_t
length) {HAL_StatusTypeDef
status;
HAL_GPIO_WritePin( CS_I2C_SPI_GPIO_Port, CS_I2C_SPI_Pin,
GPIO_PIN_RESET
);status = HAL_SPI_TransmitReceive( &hspi1, transmit, receive, length, 100);
HAL_GPIO_WritePin( CS_I2C_SPI_GPIO_Port, CS_I2C_SPI_Pin,
GPIO_PIN_SET
);
if
(status !=HAL_OK
) {
printf
(
'there is a problem with the transmit %d\r\n', status);
}
}
It gives the same dummy byte to me. I mean I set rx[0],rx[1] to 0. And after SPISend both of them will be 255. Do you think the reason might be that I am not using external clock? I don't use HSE. I set my clock speed to 16MHz.
Unfortunately, right now I can't analyze the signals to share them with you.
2017-12-11 10:04 AM
The big question is: Why my MISO pin is always high?
Is it related to configuration? Or should I write something to lis3dsh before it uses the MISO line?
2017-12-11 10:30 AM
Oh!! Finally, the problem is solved just by 3 lines of code:
SPI_send(0x25,0x90);
SPI_send(0x23,0x01);
SPI_send(0x20,0x67);
I think 'force reboot'ing solved my problem(first bit of register 0x25). Now it is working even if I comment it out. Strange. Really, I changed nothing else. I have been writing to 0x20 and 0x23 registers but I had not seen anything about 0x25.
2018-05-09 02:44 PM
I also have the same problem however my communication with Lis3dsh works fine all the time and suddenly the SPI communication stucks i tried to send reset cmd use the solution given above but still have the same issue until i un-power and power the Lis3dsh again. i tried to slower the clk (i use 2M i tried 1M and even 500K) but no response i always read 0xff if i do not use the hardware reset by unpower and power the Lis3dsh.
Is there any explication about this issue or is there any software solution for it.I will be thankful if someone help me.2018-05-16 03:44 AM
Could someone help me please still have the same issue