06-08-2020 06:23 AM
I tried to use STM32 MCU to use SPI to communicate with BMX160, but I can't get CHIPID, I already use github bmi.h and bmi.c files, please tell me which part is missing to read CHIPID normally
06-10-2020 08:14 PM
Hello~~Fish
At present, there is no oscilloscope on hand, and the SPI wave signal is attached later.
I currently have two questions. Thank you~~
1. Use BMX160 Shuttle Board to communicate through SPI, CS PIN needs set zero or one at the beginning ???
2. According to your last reply, I executed rslt = null_ptr_check(dev) in the int8_t bmi160_init (struct bmi160_dev * dev) function, and the result is zero, so it means that my SPI pre-operation should be completed?? It is just whether the MCU uses SPI to connect with BMX160 Success depends on the wave pattern?
06-11-2020 02:53 AM
1. Use BMX160 Shuttle Board to communicate through SPI, CS PIN needs set zero or one at the beginning ???
In fact, if use SPI interface, CS Pin need a raising edge after BMX160 power, from 0 to 1. You need switch CS Pin from 0 to 1 before SPI communication.
2. According to your last reply, I executed rslt = null_ptr_check(dev) in the int8_t bmi160_init (struct bmi160_dev * dev) function, and the result is zero, so it means that my SPI pre-operation should be completed?? It is just whether the MCU uses SPI to connect with BMX160 Success depends on the wave pattern?
In function bmi160_init(), dummy read will enable SPI Interface, as bellow
/* Dummy read of 0x7F register to enable SPI Interface
* if SPI is used */
if ((rslt == BMI160_OK) && (dev->interface == BMI160_SPI_INTF))
{
rslt = bmi160_get_regs(BMI160_SPI_COMM_TEST_ADDR, &data, 1, dev);
}
06-11-2020 12:27 PM - edited 06-11-2020 12:35 PM
The attachment is the wave signal diagram of my SPI
I feel there is SPI communication between MCU and BMX160
Yellow: BMX160 receives MCU Clock signal
Blue: BMX160 receives MCU signal
Purple: BMX160 signal sent to MCU
-------------------------------------------------- -------------
Currently!!! My CODE steps are as follows
1. CS =HIGH after power on
2. struct bmi160_dev bmi;
3.rslt = bmi160_init(&bmi);
-------------------------------------------------- -------------
But in run rslt = bmi160_init(&bmi);
Get the result rslt=-3 (BMI160_E_DEV_NOT_FOUND)
Will it be me bmi.read = (bmi160_com_fptr_t)user_spi_read
user_spi_read function writing error!!
06-11-2020 02:56 PM
1 CSB Pin voltage keep high, the interface is I2C. CSB voltage switch from low to high, the interface switch to SPI.
2 Check SPI configuration is right. The attachment photo isn't SPI protocol. You could refer to chapter 3.2 SPI Interface for more details.
3 From my suggestion, you could run SPI example on your platform, make sure SPI communication is OK. Then, integrate sensor driver.
I think the platform provide some example to verify SPI communication.
Hopefully, you could quickly fix this issue.
06-16-2020 10:13 AM
-----------------------------------------------------------------------------------
struct bmi160_dev bmi;
bmi.id = 0;
bmi.interface = BMI160_SPI_INTF;
bmi.read = (bmi160_com_fptr_t)user_spi_read;
bmi.write = (bmi160_com_fptr_t)user_spi_write;
bmi.delay_ms = (bmi160_delay_fptr_t) Delayus;
-----------------------------------------------------------------------------------
I would like to ask!!!
bmi.read = (bmi160_com_fptr_t)user_spi_read;
bmi.write = (bmi160_com_fptr_t)user_spi_write;
The workflow of these two functions and how to write