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.

MSP432 Master -> MSP430 Slave i2c problems

Other Parts Discussed in Thread: MSP430F5529

Hi,

I am currently trying to set up a master-slave communication via i2c between an msp432p401r (master) and an msp430f5529 (slave). I am using modified example problems for each (attached). The code is far from complete as I haven't tested anything beyond the initial i2c start command. The slave interrupts the master via a GPIO pin to trigger the gpio_isr which calls the driverlib command:

MAP_I2C_masterReceiveStart(EUSCI_B0_MODULE);

At this point, I get a NACK response from the slave (see photo below). However, for this test, the slave register UCB1I2COA is set to 0x49, and UCB0I2CSA on the master is set to 0x49, so this should acknowledge? As a result, the euscib0_isr function never runs. 

Maybe it's a simple problem that I'm just not seeing. Have I configured the interrupt incorrectly? Could anybody please help?

Thanks,

Jordan

master.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
* -------------------------------------------
* MSP432 DriverLib - v2_20_00_08
* -------------------------------------------
*
* --COPYRIGHT--,BSD,BSD
* Copyright (c) 2014, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* * Neither the name of Texas Instruments Incorporated nor the names of
* its contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* --/COPYRIGHT--*/
/*******************************************************************************
* MSP432 I2C - EUSCI_B0_MODULE I2C Slave Initiated Read from Master
*
* Description: This example demonstrates the use case where the slave needs
* to initiate a transfer from the master. This is often done in sensor
* applications and other applications where the slave has to progressively
* send data to the master when there is new data (perhaps from a sensor) to
* be sent. A GPIO port is used to wake-up the master and initiate the
* master to read data from the slave. In this case, the first byte of the
* master read will be the number of bytes (including the length byte) that
* the master should read. The GPIO pin is set as an input with a pull-up
* enabled. This is the MASTER code.
*
* ACLK = n/a, MCLK = HSMCLK = SMCLK = BRCLK = default DCO = ~3.0MHz
*
* /|\ /|\
* MSP432P401 10k 10k MSP432P401
* slave | | master
* ----------------- | | -----------------
* | P1.6/UCB0SDA|<-|----+->|P1.6/UCB0SDA |
* | | | | |
* | | | | |
* | P1.7/UCB0SCL|<-+------>|P1.7/UCB0SCL |
* | | | |
* | P1.0/GPIO|<-------->|P1.0/GPIO |
* | | | |
*
* Author: Timothy Logan
******************************************************************************/
/* DriverLib Includes */
#include "driverlib.h"
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

slave.c
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
//******************************************************************************
// Demo Application01 for MSP430/TDC7200 Interface Code Library v1.0
// Byte Read/ Byte Write TDC7200 Registers
//
// MSP430F5529
// -----------------
// /|\| XIN|-
// | | |
// --|RST XOUT|-
// | |
// | P3.0/UCB0SIMO|--> SDI
// | P3.1/UCB0SOMI|<-- SDO
// | P3.2/UCB0CLK|--> CLK
// | P2.6|--> CSB
// | P2.4|
// | |
// | P1.2|
//
// Vishy Natarajan
// Texas Instruments Inc.
// March 2013
// Built with IAR Embedded Workbench Version: 5.5x
//******************************************************************************
/* Copyright 2011-2012 Texas Instruments Incorporated. All rights reserved.
IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user who
downloaded the software, his/her employer (which must be your employer) and
Texas Instruments Incorporated (the "License"). You may not use this Software
unless you agree to abide by the terms of the License. The License limits your
use, and you acknowledge, that the Software may not be modified, copied or
distributed unless embedded on a Texas Instruments microcontroller which is
integrated into your product. Other than for the foregoing purpose, you may
not use, reproduce, copy, prepare derivative works of, modify, distribute,
perform, display or sell this Software and/or its documentation for any
purpose.
YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED �AS IS� WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL TEXAS
INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER LEGAL
EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES INCLUDING BUT NOT
LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE OR CONSEQUENTIAL
DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT OF SUBSTITUTE GOODS,
TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
*******************************************************************************/
#include <stdint.h>
#include "TI_TDC7200.h"
#include "TI_MSP430.h"
#include "TI_MSP430_hardware_board.h"
#include "TI_MSP430_spi.h"
#include "HAL_PMM.h"
#include <stdbool.h>
void Init_Clock (void);
void InitMCU(void);
// Test TDC7200 Register Read/Write & Conversion
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Jordan,

      I ran a quick test and with this code, the slave acknowledge the MSP432.

    /* --COPYRIGHT--,BSD_EX
     * Copyright (c) 2012, Texas Instruments Incorporated
     * All rights reserved.
     *
     * Redistribution and use in source and binary forms, with or without
     * modification, are permitted provided that the following conditions
     * are met:
     *
     * *  Redistributions of source code must retain the above copyright
     *    notice, this list of conditions and the following disclaimer.
     *
     * *  Redistributions in binary form must reproduce the above copyright
     *    notice, this list of conditions and the following disclaimer in the
     *    documentation and/or other materials provided with the distribution.
     *
     * *  Neither the name of Texas Instruments Incorporated nor the names of
     *    its contributors may be used to endorse or promote products derived
     *    from this software without specific prior written permission.
     *
     * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
     * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
     * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
     * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
     * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     *
     *******************************************************************************
     * 
     *                       MSP430 CODE EXAMPLE DISCLAIMER
     *
     * MSP430 code examples are self-contained low-level programs that typically
     * demonstrate a single peripheral function or device feature in a highly
     * concise manner. For this the code may rely on the device's power-on default
     * register values and settings such as the clock configuration and care must
     * be taken when combining code from several examples to avoid potential side
     * effects. Also see www.ti.com/grace for a GUI- and www.ti.com/msp430ware
     * for an API functional library-approach to peripheral configuration.
     *
     * --/COPYRIGHT--*/
    //******************************************************************************
    //  MSP430F552x Demo - USCI_B0 I2C Slave RX single bytes from MSP430 Master
    //
    //  Description: This demo connects two MSP430's via the I2C bus. The master
    //  transmits to the slave. This is the slave code. The interrupt driven
    //  data receiption is demonstrated using the USCI_B0 RX interrupt.
    //  ACLK = n/a, MCLK = SMCLK = default DCO = ~1.045MHz
    //
    // ***to be used with "MSP430F55xx_uscib0_i2c_06.c" ***
    //
    //                                /|\  /|\
    //                MSP430F5529     10k  10k     MSP430F5529
    //                   slave         |    |         master
    //             -----------------   |    |   -----------------
    //           -|XIN  P3.0/UCB0SDA|<-|----+->|P3.0/UCB0SDA  XIN|-
    //            |                 |  |       |                 |
    //           -|XOUT             |  |       |             XOUT|-
    //            |     P3.1/UCB0SCL|<-+------>|P3.1/UCB0SCL     |
    //            |                 |          |                 |
    //
    //   Bhargavi Nisarga
    //   Texas Instruments Inc.
    //   April 2009
    //   Built with CCSv4 and IAR Embedded Workbench Version: 4.21
    //******************************************************************************
    
    #include <msp430.h>
    
    volatile unsigned char RXData;
    
    int main(void)
    {
      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT
      P3SEL |= 0x03;                            // Assign I2C pins to USCI_B0
      UCB0CTL1 |= UCSWRST;                      // Enable SW reset
      UCB0CTL0 = UCMODE_3 + UCSYNC;             // I2C Slave, synchronous mode
      UCB0I2COA = 0x48 | UCOAEN;                // own address is 0x48 + enable
      UCB0CTL1 &= ~UCSWRST;                     // Clear SW reset, resume operation
      UCB0IE |= UCRXIE;                         // Enable RX interrupt
    
      while (1)
      {
        __bis_SR_register(LPM0_bits + GIE);     // Enter LPM0, enable interrupts
        __no_operation();                       // Set breakpoint >>here<< and read
      }                                         // RXData
    }
    
    // USCI_B0 Data ISR
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector = USCI_B0_VECTOR
    __interrupt void USCI_B0_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_B0_VECTOR))) USCI_B0_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
      switch(__even_in_range(UCB0IV,12))
      {
      case  0: break;                           // Vector  0: No interrupts
      case  2: break;                           // Vector  2: ALIFG
      case  4: break;                           // Vector  4: NACKIFG
      case  6: break;                           // Vector  6: STTIFG
      case  8: break;                           // Vector  8: STPIFG
      case 10:                                  // Vector 10: RXIFG
        RXData = UCB0RXBUF;                     // Get RX data
        __bic_SR_register_on_exit(LPM0_bits);   // Exit LPM0
        break;
      case 12: break;                           // Vector 12: TXIFG  
      default: break;
      }
    }

    Please give this a try and let me know if this works on your side.

      Thanks,

       David

  • Hi David,

    Many thanks for your quick reply. I was just about to test out your code when I realised the problem - I had set

    P4SEL |= 0x04,

    which meant that pins 4.0 and 4.1 were assigned as I2C pins for USCI_B1 which is incorrect - it should have been pins 4.1 and 4.2, hence

    P4SEL |= 0x06.

    This gave me the not acknowledge flag. Once I changed this my ISR begins to run. A silly mistake, especially given that the error is one of the first few lines of code.

    Thanks for your help.

    Jordan

**Attention** This is a public forum