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.

MSP430g2553 I2C LM4F232 communication

Other Parts Discussed in Thread: MSP430G2553

Hi, dear friends

      I want to communicate MSP430 with LM4F232 by I2C protocol. I have 2553 and LM4F232 launchpad. there are the MSP430 I2C examples in the CCS. but i couldn't find the M4 i2c examples. there are many questions I want to ask, please help me! (I have pull up the resistor at SCL and SDA)

    (1) In the I2C protocol, it must be defined the address for slave. In the example, (msp430g2xx3_uscib0_i2c_08) the slave address is defined 0x48h. why is the address?

   (2) I try to communicate between 430 with m4, does this plan come true,  are there many simple example to learn?

  (3) I don't connect the M4, can I look up the wave for SDA and SCL at the 430 launchpad? how to do this?

I am a new guy to learn M4, I thank you very much for your answers. 

  • There are examples. [...]\ivaWare\examples\peripherals\i2c

    paul cai said:
    I am a new gay to learn M4, I thank you very much for your answers. 

    You mean guy, don't you?

    Regards,
    Maciej 

  • thank you! and the question (1) ,(3)  .what should I do?

  • @ Maciej:

    MaciejKucia said:
    You mean guy, don't you?

    You are bit evil (and funny!)  (and way faster on the draw than this reporter...)

    I help (roadside assistance only...)

  • cb1_mobile said:
    You are bit evil (and funny!)

    Yup, I am.

    thank you! and the question (1) ,(3)  .what should I do?

    (1) It's a random number set by programmer. No specific meaning. Must be the same in master and in slave code.

    (3) Sorry but I do not understand the question. 

    Regards,
    Maciej 

  • MaciejKucia said:

    You are bit evil (and funny!)

    Yup, I am.

    thank you! and the question (1) ,(3)  .what should I do?

    (1) It's a random number set by programmer. No specific meaning. Must be the same in master and in slave code.

    (3) Sorry but I do not understand the question. 

    Regards,
    Maciej 

    [/quote]

    thank you, I have modified the example for LM4F232. I just send the data MSP430 from M4 continuously.

    (1) code for LM4F232

    #include"inc/hw_memmap.h"

    #include"inc/hw_types.h"

    #include"inc/hw_i2c.h"

    #include"driverlib/i2c.h"

    #include"driverlib/sysctl.h"

    #include"driverlib/gpio.h"

    #include"utils/uartstdio.h"

    #define NUM_I2C_DATA 3

    #define SLAVE_ADDRESS 0x48

    int

    main(void)

    {

    SysCtlClockSet(SYSCTL_SYSDIV_1 | SYSCTL_USE_OSC | SYSCTL_OSC_MAIN |

                       SYSCTL_XTAL_4MHZ);

    SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);      //I2C0 enablePB[3:2]

    SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);

    GPIOPinConfigure(GPIO_PB2_I2C0SCL);

    GPIOPinConfigure(GPIO_PB3_I2C0SDA);

    GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3);

     HWREG(I2C0_MASTER_BASE + I2C_O_MCR) |= 0x01;

    I2CMasterInitExpClk(I2C0_MASTER_BASE, SysCtlClockGet(), false);       // Initialize the I2C0 master module. I2C data transfer rate.

    I2CSlaveEnable(I2C0_SLAVE_BASE);     // Set the slave address to SLAVE_ADDRESS.

     I2CSlaveInit(I2C0_SLAVE_BASE, SLAVE_ADDRESS);

     I2CMasterSlaveAddrSet(I2C0_MASTER_BASE, SLAVE_ADDRESS, false);

    while(1)

        {

            I2CMasterDataPut(I2C0_MASTER_BASE, 0x55);

            I2CMasterControl(I2C0_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND);

            while(!(I2CSlaveStatus(I2C0_SLAVE_BASE) & I2C_SCSR_RREQ))

                   {

                   }

       }

    }

    (2) Code 2 for MSP430g2553

    #include"msp430g2553.h"

    unsignedcharRXData;

    voidmain(void)

    {

      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

      P1DIR |= BIT0;                                               // P1.0 output

      P1SEL |= BIT6 + BIT7;                     // Assign I2C pins to USCI_B0

      P1SEL2|= BIT6 + BIT7;                     // Assign I2C pins to USCI_B0

       UCB0CTL1 |= UCSWRST;                      // Enable SW reset

      UCB0CTL0 = UCMODE_3 + UCSYNC;         // I2C Slave, synchronous mode

      UCB0I2COA = 0x48;                                       // Own Address is 048h

      UCB0CTL1 &= ~UCSWRST;                     // Clear SW reset, resume operation

      UCB0I2CIE |= UCSTTIE;                     // Enable STT interrupt

      IE2 |= UCB0TXIE;                          // Enable TX interrupt

    //  TXData = 0xff;                            // Used to hold TX data

     while (1)

      {

        __bis_SR_register(CPUOFF + GIE);        // Enter LPM0 w/ interrupts

      }

    }

    // USCI_B0 State ISR

    #pragma vector = USCIAB0TX_VECTOR

    __interruptvoidUSCIAB0RX_ISR(void)

    {

    RXData = UCB0RXBUF;                       // Get RX data

      __bic_SR_register_on_exit(CPUOFF);        // Exit LPM0

    }

    my question :  there is no signal wave at the SCL and SDA, they are low level. I don't know what's wrong

  • I have no time at the moment to read your code. Are you sure you have pull up resistors on the bus?

    Regards,
    Maciej 

  • Hi Paul,

    paul cai said:
     HWREG(I2C0_MASTER_BASE + I2C_O_MCR) |= 0x01;

    This line sets the I2C in loopback mode.

    -kel

  • yes, I have pulled up the resistors to VCC on the SDA and SCL bus.

    MaciejKucia said:

    I have no time at the moment to read your code. Are you sure you have pull up resistors on the bus?

    Regards,
    Maciej 

  • "GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_2 | GPIO_PIN_3);"

    This is incorrect for LX4F - and new rebrand series.  You must instead use, "GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);

    SW-DRL-UG (newer versions) list and confirm this new requirement for LX4F and newer...

  • paul cai said:

    #pragma vector = USCIAB0TX_VECTOR

    __interruptvoidUSCIAB0RX_ISR(void)

    {

    RXData = UCB0RXBUF;                       // Get RX data

      __bic_SR_register_on_exit(CPUOFF);        // Exit LPM0

     You are serving TX Vector with rx code, again

    paul cai said:
    IE2 |= UCB0TXIE;                          // Enable TX interrupt

    Tx IRQ is enabled than RX

    On Stellaris side

     Set Master address and different Slave so it can be addressed as a slave but not receive itself.