This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28027: Configure I2C as a slave

Genius 3095 points
Part Number: TMS320F28027

Dear team:

The following code is the initialization of I2C as a slave: the host operates on the slave and the slave does not respond.

// Step1: Config Own Address (work as a slave device)
I2caRegs.I2COAR = 0x0050;

// Step2: Config Module Clock
// I2CCLK = SYSCLK/(I2CPSC+1)
#if (CPU_FRQ_40MHZ||CPU_FRQ_50MHZ)
I2caRegs.I2CPSC.all = 4; // Prescaler - need 7-12 Mhz on module clk
#endif

#if (CPU_FRQ_60MHZ)
I2caRegs.I2CPSC.all = 6; // Prescaler - need 7-12 Mhz on module clk
#endif

// Step3: Config I2C Bus SCLK clock

// Step4: Config I2C Interrupt Source
// Reference: User Guide Page26; Enable = 1, Disable = 0
I2caRegs.I2CIER.bit.AAS = 1; // Addressed as slave, poll I2CSTR.AAS
I2caRegs.I2CIER.bit.ARBL = 0; // Arbitration lost, poll I2CSTR.ARBL
I2caRegs.I2CIER.bit.ARDY = 0; // Register access ready, poll I2CSTR.ARDY
I2caRegs.I2CIER.bit.NACK = 0; // No-acknowLEDgement, poll I2CSTR.NACK
I2caRegs.I2CIER.bit.RRDY = 0; // [USED IN NON-FIFO MODE ONLY]Receive data ready, poll I2CSTR.RRDY
I2caRegs.I2CIER.bit.SCD = 0; // Stop condition detected, poll I2CSTR.SCD
I2caRegs.I2CIER.bit.XRDY = 0; // [USED IN NON-FIFO MODE ONLY]Transmit data ready, poll I2CSTR.XRDY

I2caRegs.I2CMDR.all = 0x0020; // [RECOMMENDED IN NON-INIT OPERATION] 0000 0010 0010 0000

Best regards