Part Number: MSP432P401R
Hi,
I'm trying to set up the code format for i2c communication with the master to slave sensor.
I didn't get the idea how to initialize and how to start the code.
Can anyone help me?
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Part Number: MSP432P401R
Hi,
I'm trying to set up the code format for i2c communication with the master to slave sensor.
I didn't get the idea how to initialize and how to start the code.
Can anyone help me?
Chethan,
There are several good examples to illustrate how to configure the I2C for communication. The table below shows the right ones to use for your master/slave pair for your choice of OS (either non-RTOS (driverlib) or TI-RTOS). Note that you'll need TWO LaunchPads to run these examples (1 master, 1 slave)
driverlib/ non-RTOS |
TI-RTOS | |
Master | i2c_master_w_multibyte-master_code | i2cmasterexample1 |
Slave | i2c_master_w_multibyte-slave_code | i2cslaveexample1 |
For the driverlib/non-RTOS Master example, you'll find near the top of the code the following data structure:
const eUSCI_I2C_MasterConfig i2cConfig = {
EUSCI_B_I2C_CLOCKSOURCE_SMCLK, // SMCLK Clock Source
3000000, // SMCLK = 3MHz
EUSCI_B_I2C_SET_DATA_RATE_400KBPS, // Desired I2C Clock of 400khz
0, // No byte counter threshold
EUSCI_B_I2C_NO_AUTO_STOP // No Autostop
};
You'll likely want to configure the first 3 parameters to suit your design- namely the SMCLK source and rate, and the data rate for your I2C channel. Make sure that your slave is operating at the same rate, of course.
-Bob L.
**Attention** This is a public forum