Part Number: CC2640
Other Parts Discussed in Thread: ADS1293, CC2650, SYSBIOS, CC1350
Tool/software: TI-RTOS
Hello,
I am using a modified version of the simple_peripheral example on a custom board with a CC2640F128RHB processor and a TI ADS1293 chip. The CC2640 and the ADS1293 are connected via SPI.
Before I did anything with our custom board, I loaded the unmodified LaunchPad version of simple_peripheral and was able to get the board to advertise over BLE and get its MAC address. After that, I added an RTOS task that would blink a couple of LED's at about one-half hertz. This I did mainly as a sanity check so I could look at the board and know it was still alive.
At this point I had our custom board blinking lights and advertising over BLE at the same time. So next I added code that would set up SPI, read one 16-bit word, and then close SPI. This is where I am now stuck. I can successfully open and close SPI, but if I try to transfer just one 16-bit word, the transfer hangs. It doesn't matter if I do the transfer in blocking or callback mode. In blocking mode the processor hangs, and in callback mode the callback function never executes. Has anyone else run into something like this?
The TI-RTOS version is 2.20.1.8, and the CC26xx BLE stack is version 2.2.1.18
Below are relevant code snippets that show what I wrote for callback mode.
(1) Here are the GPIO bit definitions:
#define Board_RLED IOID_13
#define Board_GLED IOID_14
#define Board_LED_ON 0
#define Board_LED_OFF 1
#define Board_SPI0_MISO IOID_4
#define Board_SPI0_MOSI IOID_3
#define Board_SPI0_CLK IOID_2
#define Board_SPI0_CSN IOID_6
#define Board_SPI_ADS1293_CSB IOID_6
#define Board_SPI_ADS1293_DRDYB IOID_11
#define Board_RST_ADS1293 IOID_0
(2) Here is how the bits are defined:
const PIN_Config BoardGpioInitTable[] = {
Board_RLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_LOW | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially on */
Board_GLED | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* LED initially off */
Board_SPI_ADS1293_DRDYB | PIN_INPUT_EN | PIN_PULLUP, /* ADS1293 data ready interrupt pin */
Board_SPI_ADS1293_CSB | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* ADS1293 chip select */
Board_SPI0_MOSI | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* SPI master out - slave in */
Board_SPI0_MISO | PIN_INPUT_EN | PIN_PULLUP, /* SPI master in - slave out */
Board_SPI0_CLK | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* SPI clock */
Board_RST_ADS1293 | PIN_GPIO_OUTPUT_EN | PIN_GPIO_HIGH | PIN_PUSHPULL | PIN_DRVSTR_MAX, /* ADS1293 chip reset */
PIN_TERMINATE
};
(3) Here is the code. The call to SPI_init() isn't shown, but it is invoked just before ADS1293_init()
SPI_Params params;
SPI_Handle handle = {0};
SPI_Transaction transaction = {0};
uint16_t txBuf[2] = {0x8000, 0};
uint16_t rxBuf[2] = {0};
uint16_t rx = 0xAAAA;
uint16_t tx = 0x5555;
SPI_Status stat;
void ADS1293TransferCallback(SPI_Handle cbHandle,SPI_Transaction *cbTransaction) {
tx = *((uint16_t *)(cbTransaction->txBuf));
rx = *((uint16_t *)(cbTransaction->rxBuf));
stat = cbTransaction->status;
}
void ADS1293_init() {
SPI_Params_init(¶ms);
params.transferMode = SPI_MODE_CALLBACK;
params.transferCallbackFxn = ADS1293TransferCallback;
params.bitRate = 1000000;
params.frameFormat = SPI_POL1_PHA0;
params.dataSize = 16;
params.mode = SPI_MASTER;
transaction.count = 1;
transaction.txBuf = txBuf;
transaction.rxBuf = rxBuf;
handle = SPI_open(0,¶ms);
if (handle != NULL) {
SPI_transfer(handle,&transaction);
SPI_close(handle);
}
}
