Page 1 of 1

write adress binary I2C

Posted: Tue Sep 21, 2021 1:02 pm
by P@T
Hi,

how to write the addresses in one go? I use a nucleoF411RE

Code: Select all

AD0 = Pin('PA0', Pin.OUT)
AD1 = Pin('PA1', Pin.OUT)
AD2 = Pin('PA4', Pin.OUT)

Code: Select all

AD2	AD1	AD0		Sequence I2C
0	0	0		0100 0000
0	0	1		0100 0010
0	1	0		0100 0100
|	|	|			|
|	|	|			|
|	|	|			|
|	|	|			|
|	|	|			|
1	1	1		0100 1110
Thank you

Re: write adress binary I2C

Posted: Tue Sep 21, 2021 1:55 pm
by P@T

Code: Select all

my_addresse = 0b010

AD0.value(my_address & 0b001)
AD1.value(my_address & 0b010)
AD2.value(my_address & 0b100)
like this ?

Re: write adress binary I2C

Posted: Tue Sep 21, 2021 4:28 pm
by P@T
I did this

Code: Select all

for my_address in range (7):
	AD0.value(my_address & 0b001)
	AD1.value(my_address & 0b010)
	AD2.value(my_address & 0b100)
	
	print(com.scan())
perfect ;)