This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC2650 and Accelerometer bma250

Other Parts Discussed in Thread: CC2650

Hi all,

I am new to ti-rtos and SPI development.

I started with the SimpleBlePeripheral example project and I added the SPI driver to communicate with the accelerometer using the smartrf06. 

I followed the user guide for the cc2650 to add the SPI driver and trying to connect SPI PORT 1 to accelerometer.

Now I always get 0x00 data when I read the register.

I will post my modified code, hoping that anyone can help me to solve this issue.

This is my Board.h

/////// Board.h /////

/* SPI Board */
#define Board_SPI0_MISO IOID_8 /* RF1.20 */
#define Board_SPI0_MOSI IOID_9 /* RF1.18 */
#define Board_SPI0_CLK IOID_10 /* RF1.16 */
#define Board_SPI0_CSN PIN_UNASSIGNED /* RF1.14, SPI0_CSN set by LCD */
#define Board_SPI1_MISO IOID_24 /* RF2.10 */
#define Board_SPI1_MOSI IOID_23 /* RF2.5 */
#define Board_SPI1_CLK IOID_30 /* RF2.12 */
//#define Board_SPI1_CSN PIN_UNASSIGNED /* RF2.6 */
#define Board_SPI1_CSN IOID_26

/* BMA 250 */
#define Board_LV_ACC_CSN IOID_24
#define Board_LV_ACC_INT1 IOID_28
#define Board_LV_ACC_INT2 IOID_29
#define Board_LV_ACC_PWR IOID_20

///////

////////////////////// Board.c ////////////////////////////////

PIN_Config BoardGpioInitTable[] = {

Board_LED1 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_LED2 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_LED3 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_LED4 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_KEY_SELECT | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
Board_KEY_UP | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
Board_KEY_DOWN | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
Board_KEY_LEFT | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
Board_KEY_RIGHT | PIN_INPUT_EN | PIN_PULLUP | PIN_HYSTERESIS, /* Button is active low */
//Board_3V3_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL, /* 3V3 domain off initially */
//Board_LCD_MODE | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* LCD pin high initially */
//Board_LCD_RST | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* LCD pin high initially */
//Board_LCD_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* LCD pin high initially */
Board_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX pin at inactive level */
//Board_SPI1_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
//Board_LV_ACC_PWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* enabling spi and acc */
//Board_LV_ACC_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
PIN_TERMINATE /* Terminate list */
}

const SPICC26XX_HWAttrs spiCC26XXDMAHWAttrs[CC2650_SPICOUNT] = {
{ /* SRF06EB_CC2650_SPI0 */
.baseAddr = SSI0_BASE,
.intNum = INT_SSI0,
.defaultTxBufValue = 0,
.powerMngrId = PERIPH_SSI0,
.rxChannelBitMask = 1<<UDMA_CHAN_SSI0_RX,
.txChannelBitMask = 1<<UDMA_CHAN_SSI0_TX,
.mosiPin = Board_SPI0_MOSI,
.misoPin = Board_SPI0_MISO,
.clkPin = Board_SPI0_CLK,
.csnPin = PIN_UNASSIGNED /* Note: LCD uses SPI0 */
//mettendo in questa linea Board_SPI0_CSN
},
{ /* SRF06EB_CC2650_SPI1 */
.baseAddr = SSI1_BASE,
.intNum = INT_SSI1,
.defaultTxBufValue = 0,
.powerMngrId = PERIPH_SSI1,
.rxChannelBitMask = 1<<UDMA_CHAN_SSI1_RX,
.txChannelBitMask = 1<<UDMA_CHAN_SSI1_TX,
.mosiPin = Board_SPI1_MOSI,
.misoPin = Board_SPI1_MISO,
.clkPin = Board_SPI1_CLK,
//.csnPin = Board_SPI1_CSN
.csnPin = Board_LV_ACC_CSN
}
};

////////////////////////////////////////////////////////////////////

///// SimpleBlePeripheral.c /////////////

static SPI_Handle LvSpiHandle;
static SPI_Params LvSpiParams;

//in the periodic Task functions

//Trying to read data from accelerometer
uint8_t read = 0x10;
uint8_t data = 0x01;

SPI_Params_init(&LvSpiParams);
//LvSpiParams.bitRate = 1000000;
//LvSpiParams.transferMode = SPI_MODE_BLOCKING;
//LvSpiParams.mode = SPI_MASTER;
//LvSpiParams.dataSize = 8;
//LvSpiParams.frameFormat = SPI_POL1_PHA1;

static PIN_State pinState;
static PIN_Handle hPin;
PIN_Config PinTable[3];
uint32_t i = 0;
PinTable[i++] = Board_LV_ACC_PWR | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL;
PinTable[i++] = Board_LV_ACC_CSN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL;
PinTable[i++] = PIN_TERMINATE;
hPin = PIN_open(&pinState, PinTable);

LvSpiHandle = SPI_open(CC2650_SPI1, &LvSpiParams);

if(!LvSpiHandle) {
return;
}

PIN_setOutputValue(hPin, Board_LV_ACC_CSN, 0);

//DECLARE TRANSACTION
SPI_Transaction spiTransaction;
spiTransaction.arg = NULL;
spiTransaction.count = 2;
spiTransaction.txBuf = &read;
spiTransaction.rxBuf = &data;
//TRANSFER THE DATA
bool ret = SPI_transfer(LvSpiHandle, &spiTransaction);

if(ret == false) {
return;
}
//CHECK TRANSFER OK
PIN_setOutputValue(hPin, Board_LV_ACC_CSN, 1);

/////////////////////

I know that the LCD is working in this example and is also uses SPI so i commented the following line in simpleBlePeripheral.c init function:

Board_openLCD();

Thank you in advance, any help will be appreciated.