Hi,
I am trying to interface ADXL362 with CC2650 SmartRF06EVB which is having CC2650-5XD module. I made changes in the board.c and board.h files and initialized SPI handle using SPI_init() and SPI_transfer() functions.
The loop back mode worked and then I tried sending data to ADXL362. Using the logic analyzer, I can see the data being transferred from CC2650 and I wanted continuous clock for SPI mode of operation, because of which i changed the mode to SPI_POL0_PHA1. As per the ADXL data sheet, the CS line is pulled low before transfer and this happens fine. But ADXL is not responding, even the clock and baud rate is same as the one we used for interfacing with another micro controller. The same ADXL works with K53 micro controller which rules out the possibility of faulty ADXL.
The SSIO_DR register remains at 0x00 throughout. Is there something which needs to be added in the code for SPI to get it working?
Please help me out..
I am attaching the code snippet below.
The hardware connections are
/* SPI Board */
#define Board_SPI0_MISO IOID_12 /* RF1.20 */
#define Board_SPI0_MOSI IOID_11 /* RF1.18 */
#define Board_SPI0_CLK IOID_10 /* RF1.16 */
#define Board_SPI0_CSN IOID_13 /* RF1.8 */
the BoardGpioInitTable() is
PIN_Config BoardGpioInitTable[] = {
Board_KEY_SELECT | 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_UART_TX | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL, /* UART TX pin at inactive level */
Board_3V3_EN | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL,
PIN_TERMINATE /* Terminate list */
};
The main code is
#include <xdc/runtime/Error.h>
#include <ti/sysbios/family/arm/cc26xx/Power.h>
#include <ti/sysbios/BIOS.h>
/* XDCtools Header files */
#include <xdc/std.h>
#include <xdc/cfg/global.h>
#include <xdc/runtime/System.h>
/* BIOS Header files */
#include <ti/sysbios/BIOS.h>
#include <ti/sysbios/knl/Task.h>
/* TI-RTOS Header files */
#include <ti/drivers/GPIO.h>
#include <ti/drivers/SPI.h>
#include "ICall.h"
#include "observer.h"
#include "simpleBLEObserver.h"
/* Header files required to enable instruction fetch cache */
#include <inc/hw_memmap.h>
#include <driverlib/vims.h>
#ifndef USE_DEFAULT_USER_CFG
#include "bleUserConfig.h"
// BLE user defined configuration
bleUserCfg_t user0Cfg = BLE_USER_CFG;
#endif // USE_DEFAULT_USER_CFG
SPI_Handle spi;
SPI_Params spiParams;
SPI_Transaction spiTransaction;
/**
* Exception handler
*/
void exceptionHandler()
{
volatile char i = 1;
while(i);
}
unsigned int i;
uint16_t temperature;
uint8_t txBuffer[3]={0x0b,0x01,0x03};
uint8_t rxBuffer[20];
#define TASK_STACK_SIZE 512
#define TASK_PRI 1
Char taskStack[TASK_STACK_SIZE];
Task_Struct taskStruct;
PIN_Handle Pin = NULL;
bool ret;
/*
* ======== main ========
*/
PIN_State state ;
void taskFxn(UArg a0,UArg a1)
{
// for(int k=0;k<100;k++)
while(1)
{
spiTransaction.count=3;
spiTransaction.rxBuf=rxBuffer;
spiTransaction.txBuf=txBuffer;
spiTransaction.arg = NULL;
// Pin=PIN_open(&state, BoardGpioInitTable);
// PIN_setOutputEnable(Pin, Board_LCD_CSN, true);
// PIN_setOutputValue(Pin, Board_SPI0_CSN, 0);
ret= SPI_transfer(spi, &spiTransaction);
while(spiTransaction.status!=SPI_TRANSFER_COMPLETED);
if(ret)
{
System_printf("SPI Bus read\n");
}
else
{
System_printf("SPI Bus fault\n");
SPI_close(spi);
}
// PIN_setOutputValue(Pin, Board_SPI0_CSN, 1);
// for(int k=0;k<1000000;k++);
// PIN_setOutputValue(Pin, Board_LCD_CSN, false);
}
}
int main()
{
PIN_init(BoardGpioInitTable);
#ifndef POWER_SAVING
/* Set constraints for Standby, powerdown and idle mode */
Power_setConstraint(Power_SB_DISALLOW);
Power_setConstraint(Power_IDLE_PD_DISALLOW);
#endif //POWER_SAVING
/* Create SPI for usage */
SPI_Params_init(&spiParams);
spiParams.bitRate =3000000;
spiParams.frameFormat = SPI_POL0_PHA1 ;
spiParams.mode = SPI_MASTER;
// spiParams.dataSize=8;
spi = SPI_open(Board_SPI0, &spiParams);
if (spi == NULL) {
System_abort("Error Initializing spi\n");
}
else {
System_printf("spi Initialized!\n");
}
spiTransaction.count=3;
spiTransaction.rxBuf=rxBuffer;
spiTransaction.txBuf=txBuffer;
spiTransaction.arg = NULL;
Task_Params params;
Task_Params_init(¶ms);
params.priority = TASK_PRI;
params.stackSize = TASK_STACK_SIZE;
params.stack = &taskStack;
Task_construct(&taskStruct, taskFxn, ¶ms, NULL);
/* enable interrupts and start SYS/BIOS */
BIOS_start();
return 0;
}
/**
* Error handled to be hooked into TI-RTOS
*/
Void smallErrorHook(Error_Block *eb)
{
for (;;);
}
/**
* HAL assert handler required by OSAL memory module.
*/
void halAssertHandler(void)
{
for (;;);
}
