Closed Visionario closed 9 years ago
I loaded the example slave.pde on a 18f4550 and with another 18f4550 I looked for the I2C devices connected to it. The slave was found with 2C as address. It is difficult for me to test your configuration. Nevertheless I shall try more tests during the next days. As you own 2 18f4550 (or 18f2550) would you try the 2 examples master.pde and slave.pde to know if the 2 boards communicate as expected.
Best regards André
The response 0x16 is in fact 0x2c shifted to the right 0x2c = 0B00101100 when 0x16=0B00010110 I prefer to use directly the 8bits address 00101100 rather than the 7bits address 0010110 which needs a left shift
Slave.pde is coded to reply to a master program according a specific protocol. Look at master.pde to better understand this protocol : When the slave receives as first character : 0x80 it replies sending its address 2C and the version number 1 0x81 it replies a message (length 4 bytes) : hi!? just for the fun 0x90 followed by 1 the slave switches on a led connected to RB6 0x90 followed by anything else 1 (0 for instance) switches off this previous led 0x90 alone the slave send the RB6 led status 1 for on, 0 for off other character different than 0x80 ,81, 90 it echoes this character +1 ( if "a" is received the reply will be "b". This example is intended to show what is possible. After trying it you have to imagine your own code. Best Regards André
Hi.
I am working with the example slave.pde ( https://github.com/PinguinoIDE/pinguino-libraries/blob/master/examples/04.Communication/i2c/slave.pde ) and connecting a raspberry Model B ver.1 using level shifters to use I2C.
I2C lines come from raspberry (SDA:3 SCL:5) to level shifters and using pull up resistors 2.2k, so, the SDA and SCL lines go to RTC DS1307 and to PIC in SDA:RB0 / SCL:RB1.
The actual example has an address 0x2c for PIC in slave mode but from raspberry it responds with 0x16 and 0x1e simultaneously!!, doing "i2cdetect -y 0" in raspberry the led on RB7 goes to intermittent (blinking) and communication failed, however, PIC still respond with same adresss (0x16 and 0x1e), after that it is neccesary to turn off and turn on the pic to start or pressing the switch to change to programming mode bootloader.
In the code (slave.pde) you can read:
but it is in setup section not in the loop, besides only blink 2 times in the start.
Calling another adress or other device, then PIC hang up again.
After turn on the PIC i can call it and works fine
calling to RTC..
After this, then stop communication..
and so on
This is the diagram and connections in protoboard: http://goo.gl/ZpYFRq
!
NOTES:
a) Using a board PinguinoVE got same results.
b) Changing PIC for another and another with bootloader 4.14 and 2.12 got same results
c) With pull up resistors or without got same results
d) Led on RB6 never turn on sending command 0x90 like example
e) All grounds are connected
x) Please excuse my english ;-)
Best Regards
@Visionario Asdrubal R. Velasquez Puerto Ordaz - Venezuela