diracsbracket
Posts: 13
Joined: Thu Jun 25, 2015 3:07 pm

Si4703 I2C initialization

Sat May 21, 2016 4:28 am

Hi..
I have the following FM Radio tuner board:
https://www.sparkfun.com/products/12938

The si4703 chip must be configured to use the I2C bus ("2-wire") mode by pulling the SDA pin low before the reset pin is activated.

I have a Pi2 with the wiring as follows:

Code: Select all

Pi2                                                        Si4703
----------------------                                     -----------
Physical pin 1 (3.3V)                                 -->  3.3V pin
Physical pin 3 (BCM numbering: GPIO02) = SDA1         -->  SDIO pin
Physical pin 5 (BCM numbering: GPIO03) = SCL1         -->  SCLK pin
Physical pin 9 (Ground)                               -->  GND pin
Physical pin 16 (BCM numbering: GPIO23 = GPIO_GEN4)   -->  nRST
The following I2C configuration code, which uses the wiringPi library works, but I cannot make sense of the GPIO numbers used:
EDIT: I forgot to mention that this code comes from: https://github.com/packetgeek and that it works out of the box on my Pi2, unlike some other code out there for this tuner.

Code: Select all

...
int resetpin = 4;
int sdiopin = 0;
...
void set_I2C_mode() {
	wiringPiSetup();

	pinMode(resetpin,OUTPUT);
	pinMode(sdiopin,OUTPUT);

	digitalWrite(sdiopin,LOW);
	sleep(.1);

	digitalWrite(resetpin,LOW);
	sleep(.1);

	digitalWrite(resetpin,HIGH);
	sleep(.1);

	return;
}
I do understand "resetpin = 4" because physical pin 16 = BCM GPIO 23 corresponds to GPIO number 4 in wiringPi.

But what about sdiopin = 0 ???
According to the gpio utility of wiringPi (used as gpio readall), the wiringPi GPIO number 0 corresponds to physical pin 11, which maps to BCM GPIO number 17 = GPIO_GEN0.
How is this pin related to I2C ??? This pin is not even connected to my Si4703 board, but somehow it seems to be part of the I2C bus?

This is why I don't understand how this sdiopin = 0 setting which seems so strange to me produces the correct i2cdetect output, with the Si4703 device detected at address 0x10.
I'm lost!

Code: Select all

[email protected]:~/si4703$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- -- -- -- -- -- -- -- -- -- -- --
10: 10 -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
However, when I tried using same code but with sdiopin = 8, i2cdetect fails and shows all addresses enabled!
wiringPi GPIO 8 corresponds to physical pin 3, which is connected to the actual SDA pin used to connect the the Si4703,
so using value 8 seemed logical to me at first.

Code: Select all

[email protected]:~/si4703$ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
70: 70 71 72 73 74 75 76 77
[email protected]:~/si4703$
Can anyone make me see the light?

Thanks!

diracsbracket
Posts: 13
Joined: Thu Jun 25, 2015 3:07 pm

Re: Si4703 I2C initialization

Sat May 21, 2016 1:32 pm

Hi,
Tim, the developer behind https://github.com/packetgeek
kindly replied to a message I sent him and acknowledged the
whole SDA init part is superfluous and that the pin number used
may be incorrect anyway.
The reason why the SDA pull down during initialization is unnecessary
is that our boards are hardwired already to support only I2C mode
(apparently two IC pins are shorted for this), and therefore only
the RST signal needs to be issued.

Tim assured me he would update his github source code.
Many thanks to him for making his code available to us!

Return to “C/C++”