Part Number:TM4C1294KCPDT
Tool/software: Code Composer Studio
Hi to you all,
I am trying the I2C0 of the TM4C1294KCPDT to send data for 12-bit DAC ( MSP4725 Evaluation board from Microchip) to get familiar with the microcontroller hardware interfaces.
Setting are:
I2C: SCL--> PortB pin2
SDA--> PortB pin3
speed 100kbps or 400kbps
Slave (MSP4725) address is 0xC0.
VDD: 3.3V
I can see on the oscilloscope that the I2C send the address 0x80 instead of 0xC0 and this causes the communication to stop as the slave wasn't selected.
I tried the MSP4725 evaluation board with the PICkit Serial analyser and the board worked as intended as I could change the voltage of the DAC output as needed.
It seems to the I2C of the TM4C1294 is at fault.
Pickit Serial Analyser: https://www.microchip.com/Developmenttools/ProductDetails/DV164122:
MSP4725 evaluation board: http://ww1.microchip.com/downloads/en/devicedoc/51669a.pdf
I am a bit surprise that the I2C didn’t work. Can anyone help me please?
Below is the simple example:
//*****************************************************************************
//
// main()
//
//*****************************************************************************
int
main(void)
{
static uint32_t ui32SysClkFreq, u32GetClock;
ui32SysClkFreq = SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0); // enable I2C0
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C0));
SysCtlPeripheralReset(SYSCTL_PERIPH_I2C0); // Reset I2C0
while(!SysCtlPeripheralReady(SYSCTL_PERIPH_I2C0)) ;
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); // enable portB (pin_B3 and Pin B2) for I2C0
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPION); // Enable portN for LED for debugging
// Configure SDA o PORTB PIN3
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
// Configure SCL o PORTB PIN2
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
// Configure PORTN PIN0 and PIN1 as output
GPIOPinTypeGPIOOutput(GPIO_PORTN_BASE, GPIO_PIN_0|GPIO_PIN_1); // debug
//Set I2C clock and speed to 100Kbps
I2CMasterInitExpClk(I2C0_BASE,SysCtlClockGet(),false); // tried this
// I2CMasterInitExpClk(I2C0_BASE,ui32SysClkFreq,false); // a120Mhz
while(I2CMasterBusy(I2C0_BASE));
I2CMasterSlaveAddrSet(I2C0_BASE,0xC0,false); set slave address
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_START);
I2CMasterDataPut(I2C0_BASE,0x0A); // send the DAC’s 4 MSB bits
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C0_BASE));
I2CMasterDataPut(I2C0_BASE,0xAA); // send the DAC’s 8 LSB bits
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_FINISH);
while(I2CMasterBusy(I2C0_BASE));
I2CMasterControl(I2C0_BASE,I2C_MASTER_CMD_BURST_SEND_STOP);
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0|GPIO_PIN_1, 3);
while(1)
{
SysCtlDelay(ui32SysClkFreq / (3 * 5) );
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 1);
SysCtlDelay(ui32SysClkFreq / (3 * 5) );
GPIOPinWrite(GPIO_PORTN_BASE, GPIO_PIN_0, 0);
}
}