2018-06-11 03:02 PM
2018-06-12 12:48 AM
However, now I only get 0xFF as the data when I debug the program.
I suspect this indicates the slave device is not answering at all.
Have you checked the lines with s acope ?
What board you working on ?
There are Discovery boards around where the connections to said accelerometer are set to I2C in hardware.
2018-06-13 03:28 PM
Try software spi first. Once you get it going, switch to hardware spi.
2018-06-13 04:50 PM
Since I'm so new to the embedded world, I do not have a scope yet. I'll definitely do some research and buy an oscilloscope.
In the meantime, is there no other reliable way to detect whether the slave device is answering at all?
I'm using the STM32F407G-DISC1 board. And it's user manual definitely states that the accelerometer uses the SPI protocol. This is what the manual says:
The STM32F407VG microcontroller controls this motion sensor through the SPI interface.
This is on page 17 of DocID022256 Rev 6. So I think SPI should be fine.
Perhaps I should use the HAL driver functions first to see if the accelerometer is responding. If the works, at least I'll know that it's an issue with my code and setup of all the configurations. If it doesn't work, then I'm sure what to do at that point.
2018-06-13 05:29 PM
A logic analyzer is much more useful here.
2018-06-13 06:22 PM
double check phase and polarity against the timing in the data sheet
2018-06-13 07:43 PM
This is what the accelerometer's data sheet says:
SPC is the serial port clock and it is controlled by the SPI master. It is stopped high when CS is high (no transmission). SDI and SDO are respectively the serial port data input and output. Those lines are driven at the
falling edge of SPC and should be captured at the rising edge of SPC.So based on this, I've set both the clock phase and clock polarity to 1. So I think I got these two right.
2018-06-13 07:44 PM
To be honest, I'm not sure what you mean by that.
2018-06-15 12:42 AM
The SPL-based firmware package for the F4 Discovery contains example code for the MEMS sensors (including the LIS3D), e.g. the demo application.
I would check the settings made there.