Other Parts Discussed in Thread: ADS7924
Tool/software: Code Composer Studio
So I am working on a custom board using the CC1352P to talk to a ADS7924 ADC over I2C. I am currently using the latest version of the CC13x2_ 26x2 3.40.0.2 SDK. The custom board does include the pull up resistors and the master (1352) is set up in callback mode.
The issue is that the I2C_open(...) returns successfully and initializes, however, when I go to make the transaction, the entire program hangs up and does not make a transfer. The code also never reaches the callback function.I am going to try and include all relevant code here.
FWI.. the main thread is being created and BIOS_start() is being called in the main_tirtos.c file. This code stemmed from the driver example called 'empty' in the SDK.
**********************************************************************
#include <ti/drivers/I2C.h>
#include <semaphore.h>
#define ADS792_SLV_ADDR 0x49
sem_t i2cSem;
I2C_Handle i2c;
I2C_Params i2cParams;
I2C_Transaction i2cTransaction;
void setup_I2C(void) {
I2C_init();
I2C_Params_init(&i2cParams);
i2cParams.bitRate = I2C_400kHz;
i2cParams.transferMode = I2C_MODE_CALLBACK;
i2cParams.transferCallbackFxn = i2cTransferCompleteFxn;
i2c = I2C_open(CONFIG_I2C_0, &i2cParams);
if (i2c != NULL) {
Display_printf(display, 0, 0, "Success in Initializing I2C");
}
}
void adcConfigRegWrite(uint8_t reg, uint8_t data) {
uint8_t txBuffer[2] = {reg, data};
i2cTransaction.slaveAddress = ADS792_SLV_ADDR;
i2cTransaction.writeBuf = (void *)txBuffer;
i2cTransaction.writeCount = 2;
i2cTransaction.readBuf = NULL;
i2cTransaction.readCount = 0;
bool transferOK;
transferOK = I2C_transfer(i2c, &i2cTransaction);
if (transferOK) {
sem_wait(&i2cSem);
Display_printf(display, 0, 0, "I2C Transfer was successful");
} else {
Display_printf(display, 0, 0, "josh");
}
}
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
/* Call driver init functions */
GPIO_init();
uint32_t status = sem_init(&i2cSem, 0, 0);
if(status == 0) {
Display_printf(display, 0, 0, "Created i2cSem");
}
setup_I2C();
adcConfigRegWrite(20, 0x60);
return 0;
}
**********************************************************************