Jump to content

unknowsman

Members
  • Content Count

    3
  • Joined

  • Last visited

  1. unknowsman

    i2C Slave not working on MSP430FR5969

    @energia When I send data over i2c but slave(MSP430FR5969) cannot read all the data with this code Its look like just only 12 characters can send . Pls give some advice. Master Code ( Arduino Mega2560): #include <Wire.h> uint8_t greeting[35] = "Hello World! and How are you today!"; void setup() { Serial.begin(250000); Wire.begin(); } void loop() { if (Serial.available() > 0) { byte inByte = Serial.read(); if (inByte == '1') { Wire.beginTransmission(0x23); Wire.write(greeting, 35); Wire.endTransmission(); } } } Slave Code(MSP430FR5969) : #include <Wire.h> void setup() { Wire.setModule(0); Wire.begin(0x23); // join i2c bus with address #0x23 Wire.onReceive(receiveEvent); // register event Serial.begin(115200); // start serial for output } void loop() { delay(100); } // function that executes whenever data is received from master // this function is registered as an event, see setup() void receiveEvent(int bytes) { if (Wire.available() != 0) { for (int i = 0; i < bytes; i++) { Serial.write(Wire.read()); } Serial.println(); } } thank you very much
  2. unknowsman

    i2C Slave not working on MSP430FR5969

    thank you so much
  3. i try to use this example but nothing happened // Wire Slave Sender // by Nicholas Zambetti <http://www.zambetti.com> // Demonstrates use of the Wire library // Sends data as an I2C/TWI slave device // Refer to the "Wire Master Reader" example for use with this // Created 29 March 2006 // This example code is in the public domain. #include <Wire.h> void setup() { Wire.setModule(0); Wire.begin(2); // join i2c bus with address #2 Wire.onRequest(requestEvent); // register event } void loop() { delay(100); } // function that executes whenever data is requested by master // this function is registered as an event, see setup() void requestEvent() { Wire.write("hello "); // respond with message of 6 bytes // as expected by master } and this one // Wire Master Reader // by Nicholas Zambetti <http://www.zambetti.com> // Demonstrates use of the Wire library // Reads data from an I2C/TWI slave device // Refer to the "Wire Slave Sender" example for use with this // Created 29 March 2006 // This example code is in the public domain. #include <Wire.h> void setup() { Wire.setModule(0); Wire.begin(); // join i2c bus (address optional for master) Serial.begin(9600); // start serial for output } void loop() { Wire.requestFrom(2, 6); // request 6 bytes from slave device #2 while(Wire.available()) // slave may send less than requested { char c = Wire.read(); // receive a byte as character Serial.print(c); // print the character } delay(500); } with this pin thank you
×