Hi,
I'm trying to communicate with BMI160 in the DA14681 Development Kit.
I am using the peripherals_demo example and trying to call the bmi160_get_chip_id to test the connection. However, it just returns 0xff, instead of the actual chip ID which is D1.
dev = ad_spi_open(BMI160);
uint8_t wbuf[2] = {0};
ad_spi_transact(dev, wbuf, 1, reg_data, 1);
if (reg_data[0] == 0xD1)
{
reg_data[1] = 0xA;
}
else
{
reg_data[2] = 0x05;
}
ad_spi_close(dev);
The pins are configured as follows:
hw_gpio_pinconfig(hw_gpio_port_3,hw_gpio_pin_2,output_push_pull,spi_clk,true),
HW_GPIO_PINCONFIG(HW_GPIO_PORT_3, HW_GPIO_PIN_0, OUTPUT_PUSH_PULL, SPI_DO, true),
hw_gpio_pinconfig(hw_gpio_port_3,hw_gpio_pin_1,输入,spi_di,true),
HW_GPIO_PINCONFIG(HW_GPIO_PORT_3, HW_GPIO_PIN_3, OUTPUT_PUSH_PULL, SPI_EN, true),
SPI_SLAVE_DEVICE(SPI1, BMI160, HW_GPIO_PORT_3, HW_GPIO_PIN_3,
HW_SPI_WORD_8BIT, HW_SPI_POL_HIGH, HW_SPI_PHA_MODE_1,
HW_SPI_FREQ_DIV_2, HW_DMA_CHANNEL_0);
谢谢,
Sam
Hi ImagineSam,
I dont see any issues on the code that you have attached. The pro kit daughterboard that you are using has a QFN or a CSP package ? Since the port 3 is not available on the CSP package. Also try to test that with a logic analyser and check if there are signals comming out of the 680, in order to verify that the code toggles the pins.
Thanks MT_dialog
Hi MT_dialog,
The package is the QFN (I believe the DA14681 Wearable kit only comes in this package?).
The read and write functions seem to be working in the wearable device firmware (DA14681_WRBL_v_1.150.6) that is provided but when using the same pins in a more lightweight project it fails to work. Is it possible that there are other required configurations to make it work?
Sincerely,
Sam
Hi ImagineSam,
Yes, the wearble comes to an QFN package (you didn't mentioned which kit you where using).
Had a look in the datasheet of the BMI160 p88 on that datasheet that i have, well it seems that the sensor requires that first bit of the byte sequence when you are about to read should be '1', so actually what you should send from the 68x is 0x80 and not 0x00, if you place 0x80 in the wbuf instead of 0x00 you will get the id that the BMI replies.
Thanks MT_dialog
MT_dialog,
对不起,这是我的不好,我的意思是在DA14681穿戴开发套件中写下“BMI160”。
I added the following line as you suggested but it still doesn't work.reg_data为设备ID返回0。
wbuf[0] = wbuf[0] | 0x80;
I have also tried it using this method which is how it's executed in the wearable firmware and it doesn't work either:
uint8_t reg_addr = 0x00;
uint8_t reg_data[10] = {0};
spi_transfer_data transfers[2] = {
{®_addr, NULL, 1},
{null,reg_data,cnt}
};
reg_addr = reg_addr | 0x80;
ad_spi_complex_transact(dev, transfers, 2);
void ad_spi_transact(spi_device dev, const uint8_t *wbuf, size_t wlen, uint8_t *rbuf, size_t rlen);
谢谢,
Sam
Hi ImagineSam,
Tested on a wearable board using the ble_adv example with the appropriate mods offcourse in order to enable the SPI hardware and the SPI adapters using the below #defines:
#define dg_configSPI_ADAPTER
#define dg_configUSE_HW_SPI
With the instructions below, i could see in debug mode that the data send back from the sensor is one byte 209 dec or 0xD1 which indicates the id of the BMI160.
bmi160_dev = ad_spi_open(BMI160);
data_wbuf[0]|=0x80;
ad_spi_transact(bmi160_dev, data_wbuf, 1, reg_data, 1);
Thanks MT_dialog
Hi MT_Dialog
谢谢,使用ble_adv example我能够让它像你一样工作!我有一个实际的数据流进入。
但是否有任何想法为什么它在一个项目中工作而不是其他项目?我试过了peripherals_demoandpxp_reporter
SDK可以是一个问题吗?BLE_ADV.didn't work for me in 1.0.10 sdk which is what I used for the other projects but when I changed to 1.0.12 ble_adv started working.
Sincerely,
Sam
Hi ImagineSam,
Perhaps you missed any configuration, the peripherals demo is a quite loaded demo with a bunch of configurations and setups and you can easily miss something, in any case the SDK 1.0.12 is the latest version of the SDK and also i 've tested the same code and using the exact same settings on the SDK 1.0.10 and it operates on that SDK as well in the ble_adv demo.
Thanks MT_dialog