SPI based BMI055 Accelerometer. Issue

2 posts / 0 new
Last post
Baswaraj
Offline
Last seen:4 years 7 months ago
加入:2015-05-20 07:18
SPI based BMI055 Accelerometer. Issue

你好,

We're attempting to communicate with an SPI based BMI055 Accelerometer.

Here is our setup:
o P0_0 SPI Clock
o P0_1 LF_Enable (CS)
o P0_5 MISO
o P0_6 MOSI

And this is the code:
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_0, OUTPUT, PID_SPI_CLK, false ); // Clock
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_1, OUTPUT, PID_SPI_EN, true ); // CS
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_5, INPUT, PID_SPI_DI, false ); // MISO
GPIO_ConfigurePin( GPIO_PORT_0, GPIO_PIN_6, OUTPUT, PID_SPI_DO, false ); // MOSI
// …
spi_init(&cs_pad_param, // Note: This point to the pin and port of the CS line
SPI_MODE_8BIT,
SPI_ROLE_MASTER,
SPI_CLK_IDLE_POL_LOW,
SPI_PHA_MODE_1,
SPI_MINT_DISABLE,
SPI_XTAL_DIV_8);

And a simple read register code:
spi_cs_high();
spi_set_bitmode(SPI_MODE_8BIT);
spi_access((uint8_t)(READ_MODE|address));//address is 0x00h
regval = (uint8_t)spi_access(0x0000); // Note : regval is always 0xff
spi_cs_low();

Now, the read attempt always returns 0xff (the value at address 0x50001202),
We know for sure that this is wrong as we are attempt to read a default value which should be 0xFA .

Thank you,

Baswaraj.

Device:
MT_dialog
Offline
Last seen:1 week 4 days ago
Staff
加入:2015-06-08 11:34
嗨Baswaraj,

嗨Baswaraj,

Are you able to take a capture of bus activity in order to check if the sensor is responding to the commands. Also have you initialize the SPI ? Additionally please try to invoke spi_cs_low() to start a transaction and then spi_cs_high to end it.

Thanks MT_dialog