Trouble talking to a AS5048B via I2C

As the topic title says I’m having trouble getting a AS5048B sensor to talk to a Wixel via I2C. I’ve used I2C to connect Wixels to other devices but this one is giving me difficulty.

At the moment I’m just trying to get it to respond to the Wixel sending out it’s address but all I get are timeouts (no ACK or NACKs). I also wrote a quick scanning app that pings all addresses from 0 to 127, but it returns nothing but timeouts as well. Scanning with other I2C devices connected works as expected.

I’ve connected the AS5048B to an Arduino Uno without any hassle. The Uno is a 5V device, but the AS5048B supports both 5V and 3.3V operation so hopefully that won’t have any bearing on the problem.

Here’s the datasheet: https://media.digikey.com/pdf/Data%20Sheets/Austriamicrosystems%20PDFs/AS5048A,B.pdf

And here’s the main loop from my scanning app:

void main()
{
	uint8 i2cAddress = 0;
	BIT nack;

	systemInit();
	usbInit();

	i2cPinScl = param_scl_pin;
	i2cPinSda = param_sda_pin;

	while(1)
	{
		boardService();
		updateLeds();
		usbComService();
		sendTextToUSB();

	    if (getMs() - lastUpdate >= 100)
	    {
	    	if(i2cAddress < 128)
	    	{
	    		i2cStart();
				nack = i2cWriteByte(i2cAddress << 1);
				if (!i2cTimeoutOccurred)
				{
					printf(" %d responded with a", i2cAddress);
					if (nack)
					{
						printf(" NACK.\r\n");
					}
					else
					{
						printf(" ACK.\r\n");
					}
				}
				else
				{
					i2cTimeoutOccurred = 0;
				}
				i2cAddress++;
	    	}
	    	else
	    	{
	    		printf("Scan complete.\r\n");
	    		i2cAddress = 0;
	    	}

	    	lastUpdate = getMs();
	    }
	}
}

Thanks in advance for any assistance you can give.

Hello.

When the Wixel’s I2C library reports a timeout, it means that the SCL line is reading low for a long time. I see you are not enabling the Wixel’s internal pull-up resistors in your code. Did you connect external pull-ups to ensure that SCL and SDA both get pulled high? Could you use a multimeter to verify that SCL and SDA are both high when your code is not trying to use I2C?

–David

Cheers David,

When I looked at the serial_i2c app I didn’t see any code to enable the pull up resistors and assumed that was because they were enabled by default. I’ve tried enabling the pull-ups using setDigitalInput before the while loop in main(), but it hasn’t had any effect.

Checking SCL and SDA with the I2C functions commented out shows them both high at a smidge over 3.2V.

Righto, I’ve had a bit of a dig around and I’ve found a solution that seems to work.

In the I2C library there are two functions:

BIT i2cReadScl(void)
{
setDigitalInput(i2cPinScl, HIGH_IMPEDANCE);
return isPinHigh(i2cPinScl);
}

BIT i2cReadSda(void)
{
setDigitalInput(i2cPinSda, HIGH_IMPEDANCE);
return isPinHigh(i2cPinSda);
}

You’ll note that setDigitalInput uses HIGH_IMPEDANCE for the second argument, which disables the pull-up resistors. If I change that to PULLED for both functions everything works, I’ve tested the change with other I2C devices and it doesn’t appear to have caused any problems.

Checking the schematics for the other I2C devices I’ve used they have their own pull-up resistors, so that explains why it worked with them.

1 Like