Hello everyone! im here again for the 3rd time to ask for some advice/help. This forum has been so helpful!
Recently i've implemented some code on a msp430g2553 to read a 7 segment LED display. My next step is to send that reading to another msp430 or maybe a c2000 micro-controller.
End goal: Msp430-1 decodes the LED display and sends 2 digit number to the Msp430-2 then i display the numbers on my monitor.
I was looking at the "wire" master write and slave read examples. I have implemented them but they seem not to work, i'm not sure of a couple of things. How do i address SCL and SDA ? how do i rout them to the specific pin?
Wire.begin(4); // join i2c bus with address #4
is 4 the pin for SDA? where do i tell energia where my SCL pin is?
I am attaching the examples i'm using in order to get more familiar with this "wire" method.
Do I have to change the orientation of the TX and RX jumpers?(see picture)
PS. is there any other communication protocol that i could use for my application? maybe something easier? or something where i could see a clear example of??
Thanks in advance for all the help and comments.
// Wire Master Writer
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Writes data to an I2C/TWI slave device
// Refer to the "Wire Slave Receiver" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include <Wire.h>
void setup()
{
Wire.begin(); // join i2c bus (address optional for master)
}
byte x = 0;
void loop()
{
Wire.beginTransmission(4); // transmit to device #4
Wire.write("x is "); // sends five bytes
Wire.write(x); // sends one byte
Wire.endTransmission(); // stop transmitting
x++;
delay(500);
}
//======================================================================================//======================================================================================
//this goes in the other msp430
// Wire Slave Receiver
// by Nicholas Zambetti <http://www.zambetti.com>
// Demonstrates use of the Wire library
// Receives data as an I2C/TWI slave device
// Refer to the "Wire Master Writer" example for use with this
// Created 29 March 2006
// This example code is in the public domain.
#include <Wire.h>
void setup()
{
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // 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 howMany)
{
while(1 < Wire.available()) // loop through all but the last
{
char c = Wire.read(); // receive byte as a character
Serial.print(c); // print the character
}
int x = Wire.read(); // receive byte as an integer
Serial.println(x); // print the integer
}