I have looked at the i2c_comm master example and had it working with uc_iii to send between I2C0 and 1 on the same board. Right now I'm running this in BM_OS. Will look at the EEPROM example.
Definitely have the open drains enabled in my pin-setup:
/***** I2C PINS *****/
/* I2C0 */
/* PORTB_PCR2 - CLOCK */
PORT_HAL_SetMuxMode(g_portBaseAddr[1], 2u, kPortMuxAlt2);
PORT_HAL_SetOpenDrainCmd(g_portBaseAddr[1], 2u, true);
/* PORTB_PCR3 - DATA */
PORT_HAL_SetMuxMode(g_portBaseAddr[1], 3u, kPortMuxAlt2);
PORT_HAL_SetOpenDrainCmd(g_portBaseAddr[1], 3u, true);
External pull-ups are used. Right now they are 10k's, but I have tried two other values (1k, 2.2k) with the same results in terms of RX working, TX not.
Declared locally to the function :
/***** I2C VARS *****/
i2c_master_state_t i2c0_master_state;
i2c_status_t i2c_status;
i2c_device_t
i2c0_codec =
{
.address = 0x10, (Actually 0x20 and 0x21)
.baudRate_kbps = 400
};
/***** I2C TX/RX VARIABLES *****/
uint8_t cmdbuff[1];
uint8_t txbuff[1];
uint8_t rxbuff[1];
Init:
/****** INITIALIZE I2C ******/
I2C_DRV_MasterInit(0, &i2c0_master_state);
/***** TEST REMOVE AFTERWARDS *****/
cmdbuff[0] = 0x26;
rxbuff[0] = 0;
i2c_status = I2C_DRV_MasterReceiveDataBlocking(0, &i2c0_codec, cmdbuff,
sizeof(cmdbuff), rxbuff, sizeof(rxbuff), 500);
^ THIS SETS rxbuff[0] TO 0x80 WHICH IS THE VALUE OF 0x26 in the codec after Reset... good to go
cmdbuff[0] = 0x26;
txbuff[0] = (0 | (1 << 6));
i2c_status = I2C_DRV_MasterSendDataBlocking(0, &i2c0_codec, cmdbuff,
sizeof(cmdbuff), txbuff, sizeof(txbuff), 500);
^ THIS SENDS THE ADDRESS, SLAVE ACKS, however the function that should set IICIE does not set that bit (bit 6), so it doesn't go through the ISR after HAL Send Start, producing 0x04 time out for the status.
------
I had the cmdbuff, tx and rxbuff set as pointers, but I was getting compiler errors for passing arguments of incompatible type, which makes sense I think because a declaration of an array is already a pointer. Other than that, I'm stupmed, and thank you for the quick response.