Go Down

Topic: Arduino due as slave in i2c (Read 57 times) previous topic - next topic

chutki

Apr 21, 2017, 12:28 pm Last Edit: Apr 21, 2017, 12:35 pm by chutki
 DUE is slave in i2c and the master is Atmel AVR. The following code is the parameter passed for i2c write for Master.

 
Code: [Select]
typedef struct {
/* ! TWI chip address to communicate with. */
char chip;
/* ! TWI address/commands to issue to the other chip (node). */
uint8_t addr[3];
/* ! Length of the TWI data address segment (1-3 bytes). */
int addr_length;
/* ! Where to find the data to be written. */
uint8_t *buffer;
/* ! How many bytes do we want to write. */
unsigned int length;

} twi_package_t;


  Here the chip address is the slave address. In
Code: [Select]
Wire.begin(0x02) the slave address is defined. The problem here is the TWI Address/commands. What must I mention for Arduino? Usually there is nothing mentioned here.

weird_dave

Does this help?
https://www.arduino.cc/en/Tutorial/MasterWriter

chutki

#2
Apr 21, 2017, 04:50 pm Last Edit: Apr 21, 2017, 04:57 pm by chutki
not actually :(  ,because I program the i2c  master in Atmel avr in Atmel studio and Arduino as slave in Arduino IDE. The code above id for the Master in Atmel studio. In the second parameter we have to mention the slave's code to write the data in it. But in arduino, just address of the slave is present. So what should be mentioned ?

weird_dave

The arduino address is the address the AVR master needs to use to talk to the arduino, there is arduino slave code listed in the previous link, below the arduino master code.
Note that the master and slave code are using the same address, because the master is addressing the slave, by the slave address. The master has no address of its own (unless you make it a slave as well).
Does that help, or have I not understood the problem?

chutki

The arduino address is the address the AVR master needs to use to talk to the arduino
Yes this is the slave's address. It is clear. My point is ,my master is programmed in another IDE. I have included that code part earlier. It asks for the "slave address"  and it asks for another parameter called "slave memory address" - it says at which address in the slave should I write my data? . This is my doubt.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy