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.

TMS320F28069: Problem with I2C Read/write on IO expander PCA9536D

Part Number: TMS320F28069
Other Parts Discussed in Thread: PCA9536

Hello,

I used I2C bus on my own board with EEPROM 24EE256 and PCA9536 driving by F28069. Address are OK : one is 0x50 (EEPROM) and other 0x41 for PCA.

With EEPROM, everything is ok and works perfectly with the code but IO expander never answers to write or read request.

I send a write command every 20 ms. I haven't any errors. I joined scope printscreen and source code.

I use  " Uint16 I2C_Write_Data(Uint16 Slave_address, Uint16 Register, Uint16 Data) "  such as

I2C_Write_Data(0x41, 0x0001, 0x0000); // every 20 ms

I request to write register 0x1 with 0x0 to the device address 0x41 but at the oscilloscope, I see only address 0x41 and no data ?!? Why ?

Could you please let me know if you have an idea. Thanks for your help

OL

//##################### I2C_Write_Data #################################################################################
// Function Name: void I2C_Write_Data
// Return Type: Uint16
// Arguments: Uint16 Slave_address, Uint16 Register, Uint16 Data
// Description: I2C_Write_Data
//#################################################################################################################
Uint16 I2C_Write_Data(Uint16 Slave_address, Uint16 Register, Uint16 Data)//
{
	Uint16 ii = 0;
	Uint16 TimeOutI2C = 0;

		I2caRegs.I2CMDR.bit.IRS = 1; 				// reset I2C

		__asm(" RPT #10 || NOP");

		// Make sure I2C is not busy and has stopped
		while (I2caRegs.I2CSTR.bit.BB == 1) //;		// busy loop
		{
				TimeOutI2C++;
				if(TimeOutI2C > 20000)
					return 0;
		}
		TimeOutI2C = 0;

		// Clear the SCD bit (stop condition bit)
		I2caRegs.I2CSTR.bit.SCD = 1;				// Clear the SCD bit (stop condition bit)

		while(I2caRegs.I2CMDR.bit.STP == 1) //;		// stop bit loop
		{
				TimeOutI2C++;
				if(TimeOutI2C > 20000)
					return 0;
		}
		TimeOutI2C = 0;

		// code d'origine
		//##################################################
		I2caRegs.I2CSAR = Slave_address;

		//still busy?
		while(I2caRegs.I2CMDR.bit.STP != 0){
			TimeOutI2C++;
			if(TimeOutI2C > 20000)
				return 0;
		}
		TimeOutI2C = 0;

		// Start bit, write mode, Higher 16 address bits, Master, Repeat mode.
		I2caRegs.I2CMDR.bit.TRX = 1; //TRANSMIT_MESSAGE;

		I2caRegs.I2CDXR = Register; // Register

		//##################################################//
		I2caRegs.I2CMDR.all = 0x26A0; //01 00 11 01 01 00 000
		//I2caRegs.I2CMDR.all = 0x27A0; //01 00 11 01 01 00 000
	/*	I2caRegs.I2CMDR.bit.NACKMOD = 0;		// NACK mode bit
		I2caRegs.I2CMDR.bit.FREE 	= 1;		// Stop I2C when suspended
		I2caRegs.I2CMDR.bit.STT 	= 0;		// START condition bit
		I2caRegs.I2CMDR.bit.STP 	= 0;		// STOP condition bit
		I2caRegs.I2CMDR.bit.MST 	= 1;		// Master mode
		I2caRegs.I2CMDR.bit.TRX 	= 1;		// Transmitter mode
		I2caRegs.I2CMDR.bit.XA 		= 0;		// 7-bit addressing mode
		I2caRegs.I2CMDR.bit.RM 		= 1;		// Repeat Mode
		I2caRegs.I2CMDR.bit.DLB 	= 0;		// Digital loopback mode is disabled
		I2caRegs.I2CMDR.bit.IRS 	= 1;		// The I2C module is enabled
		I2caRegs.I2CMDR.bit.STB 	= 0;		// The I2C module is not in the START byte mode
		I2caRegs.I2CMDR.bit.FDF 	= 0;		// Free data format mode is disabled
		I2caRegs.I2CMDR.bit.BC 		= 000;		// 8 bits per data byte
		*/

		//(Lower 16) address bits
		while(I2caRegs.I2CSTR.bit.ARDY != 1){
			TimeOutI2C++;
			if(TimeOutI2C > 20000)
				return 0;
		}
		TimeOutI2C = 0;

		I2caRegs.I2CDXR = Data;  //

		while (I2caRegs.I2CSTR.bit.NACK == 1) // Clear if NACK received
		{
			I2caRegs.I2CSTR.bit.NACK = 1;

			TimeOutI2C++;
			if(TimeOutI2C > 20000)
				return 0;
		}
		TimeOutI2C = 0;

		I2caRegs.I2CMDR.all = 0x0EA0;
	/*	I2caRegs.I2CMDR.bit.NACKMOD = 0;		// NACK mode bit
		I2caRegs.I2CMDR.bit.FREE 	= 1;		// Stop I2C when suspended
		I2caRegs.I2CMDR.bit.STT 	= 0;		// START condition bit
		I2caRegs.I2CMDR.bit.STP 	= 1;		// STOP condition bit
		I2caRegs.I2CMDR.bit.MST 	= 1;		// Master mode
		I2caRegs.I2CMDR.bit.TRX 	= 0;		// Transmitter mode
		I2caRegs.I2CMDR.bit.XA 		= 0;		// 7-bit addressing mode
		I2caRegs.I2CMDR.bit.RM 		= 0;		// Nonrepeat mode
		I2caRegs.I2CMDR.bit.DLB 	= 0;		// Digital loopback mode is disabled
		I2caRegs.I2CMDR.bit.IRS 	= 1;		// The I2C module is enabled
		I2caRegs.I2CMDR.bit.STB 	= 0;		// The I2C module is not in the START byte mode
		I2caRegs.I2CMDR.bit.FDF 	= 0;		// Free data format mode is disabled
		I2caRegs.I2CMDR.bit.BC 		= 000;		// 8 bits per data byte
	*/

		while(I2caRegs.I2CSTR.bit.SCD != 1){
			TimeOutI2C++;
			if(TimeOutI2C > 20000)
				return 0;
		}
		TimeOutI2C = 0;

		I2caRegs.I2CSTR.bit.SCD = 1; // Clear stop condition

		return 1;
	}

  • Hi OL,

    It looks like the PCA9536 slave device is not responding to the 0x41 address and the F28069 is receiving a NACK. If you check the 9th clock cycle, the ACK/NACK bit in your waveform is a 1. Your PCA9536 slave device should pull the SDA line (green) low to Acknowledge the slave address.

    Best,

    Kevin

  • Hi Kevin

    Thanks for your reply. Ok for the NACK but why ? I didn't find why. Do u have an idea ?

    Regards,

    Ol

  • Hi OL,

    Checking the PCA9536 datasheet 0x41 is the correct slave address to use. It may be a hardware related issue, that's the first thing that comes to mind.

    • Can you confirm proper circuitry and connections for the PCA9536 device? Feel free to share the portion of the schematic here for me to review.
    • Maybe the PCA9536 device has been damaged somehow. Are you able to replace this component with a new one?
    • One other thing you could try is using a slower I2C frequency, like 100 KHz, and see if that works

    Best,

    Kevin

  • Hi Kevin,

    Thank you for your answer and help. I have with an EEPROM 24AA256 who works well. So connections should be ok.

    I tried @125 kHz, it is the same..

    here is the schematic

    On Monday, I will try an other board or to change PCA.

    Anyway if you have other ideas i took them !

    Have a good week end

    regards

    Olivier

  • Hi Olivier,

    The schematic looks fine, don't see any issues.

    For the waveforms you've captured and provided are you probing physically close to the PCA9536 device? I assume you are, but just to check. It seems like the issue may be a bad PCA9536 part.

    One other thought I had is checking if the internal pull-ups of the F2806x device are enabled. They are enabled by default and you have to disable them by setting the respective GPAPUD / GPBPUD register bits to 1. Maybe the internal pull-ups are affecting the PCA9536's ability to pull the SDA line low.

    Best,

    Kevin