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.

msp430 f5529 I2c on usc_b1

Other Parts Discussed in Thread: MSP-EXP430F5529LP, MSP-TS430PN80USB, MSP430F5529, MSP430F5528

Hi,

I am trying to enable  an I2C slave on a TI launchpad with an msp430 f5529 with ucs_b1. 

The slave is working properly for all pins except the default mapped ones: pin 4.1 and 4.2.

I am using an arduino uno as I2C master with pullups on the SDA and SCL to 3.3 v. (and connected the ground as well).

 Below is a code snipped of how I map those pins (based on the USC_B0 example from TI). I have really no clue why I am not able to use pin 1 and 2 of port 4. I tried now on 2 different lauchpads to rule out hardware issues but no success so far.

//******************************************************************************

//   Built with CCSv6 
//******************************************************************************
#include <msp430f5529.h>
//#define MAPSDASLAVE1 P4MAP1
//#define MAPSCLSLAVE1 P4MAP2
#define MAPSDASLAVE1 P4MAP0
#define MAPSCLSLAVE1 P4MAP3
//#define MAPSDASLAVE1 P4MAP4
//#define MAPSCLSLAVE1 P4MAP5
void Port_Mapping(void);


// i2c transmit data
unsigned char *PTxData;                     // Pointer to TX data
const unsigned char TxData[] =              // Table of data to transmit
{
		0x24,
  0x30,
  0x31,
  0x32,
  0x33,
  0x34,
  0x35,
  0x30,
    0x31,
    0x32,
    0x33,
    0x34,
    0x35,
    0x30,
      0x31,
      0x32,
      0x33,
      0x34,
      0x35,
      0x30,
        0x31,
        0x32,
        0x33,
        0x34,
        0x35

};

int main(void)
{
  WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT



  Port_Mapping();

  P4DIR |= 0xFF;                            // P4.0 - P4.7 output
  P4SEL |= 0xFF;                            // P4.0 - P4.6 Port Map functions
  UCB1CTL1 |= UCSWRST;                      // Enable SW reset
  UCB1CTL0 = UCMODE_3 + UCSYNC;             // I2C Slave, synchronous mode
  UCB1I2COA = 0x48;                         // Own Address is 048h
  UCB1CTL1 &= ~UCSWRST;                     // Clear SW reset, resume operation
  UCB1IE |= UCTXIE + UCSTPIE + UCSTTIE+ UCRXIE;     // Enable STT and STP interrupt
  while (1)
  {
    PTxData = (unsigned char *)TxData;      // Start of TX buffer

    __bis_SR_register(LPM0_bits + GIE);     // Enter LPM0, enable interrupts
                                            // Remain in LPM0 until master
                                            // finishes RX
    __no_operation();                       // Set breakpoint >>here<< and
  }                                         // read out the TXByteCtr counter
}





// PORT mapping
void Port_Mapping(void)
{
//  unsigned char i;
//  volatile unsigned char *ptr;
  __disable_interrupt();                    // Disable Interrupts before altering Port Mapping registers
  PMAPPWD = 0x02D52;                        // Enable Write-access to modify port mapping registers

  #ifdef PORT_MAP_RECFG
  PMAPCTL = PMAPRECFG;                      // Allow reconfiguration during runtime
  #endif

  MAPSDASLAVE1 = PM_UCB1SDA;
  MAPSCLSLAVE1 = PM_UCB1SCL;


  PMAPPWD = 0;                              // Disable Write-Access to modify port mapping registers
  #ifdef PORT_MAP_EINT
  __enable_interrupt();                     // Re-enable all interrupts
  #endif

}


//------------------------------------------------------------------------------
// The USCI_B0 data ISR TX vector is used to move data from MSP430 memory to the
// I2C master. PTxData points to the next byte to be transmitted, and TXByteCtr
// keeps track of the number of bytes transmitted.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// The USCI_B0 state ISR TX vector is used to wake up the CPU from LPM0 in order
// to do processing in the main program after data has been transmitted. LPM0 is
// only exit in case of a (re-)start or stop condition when actual data
// was transmitted.
//------------------------------------------------------------------------------
#pragma vector = USCI_B1_VECTOR
__interrupt void USCI_B1_ISR(void)
{
  switch(__even_in_range(UCB1IV,12))
  {
  case  0: break;                           // Vector  0: No interrupts
  case  2: break;                           // Vector  2: ALIFG
  case  4: break;                           // Vector  4: NACKIFG
  case  6:                                  // Vector  6: STTIFG
    UCB1IFG &= ~UCSTTIFG;                   // Clear start condition int flag
    break;
  case  8:                                  // Vector  8: STPIFG
    UCB1IFG &= ~UCSTPIFG;                   // Clear stop condition int flag
    	__bic_SR_register_on_exit(LPM0_bits);   // Exit LPM0 if data was transmitted
    break;
  case 10:                            // Vector 10: RXIFG
	 
	  break;
  case 12:                                  // Vector 12: TXIFG
	  UCB1TXBUF = *PTxData++;                 // Transmit data at address PTxData
    break;
  default: break;
  }
}

For your information: I have also tried with driverlib and I have exactly the same isue (all pins are useable for I2C slave exect P4.1 and 4.2)

  • Hi,

    have you tried not to set P4DIR bits? Will this make a difference?

  • I've tried, I even tried setting them to 0 but still I get no i2c communication .

    Does TI have any workin sample code on using USCB1 with I2C?  So far I have only find examples with USCB0 or people who have questions on how to use USCB1 with I2C?

  • small update: I have tried to map I2c to any combination on port 4.

    result: any combination that used p4.1 or p4.2 has no i2c response. all other combination work properly as an I2C slave

  • P4.1 and P4.2 are connected to the booster pack header. Do you have a booster pack attached? It might put a signal on the pins that block I2C.

  • Hi Pieter,

    Jens-Michael might have a point here. I just tested it with both MSP430F5529 master (on MSP-TS430PN80USB) -slave (on MSP-EXP430F5529LP) using P4.1 and P4.2 as SDA and SCL respectively, and I can see the I2C lines working very well on my oscilloscope.

    Here is my test code:

    1373.test_i2c_p40_p41.zip

  • Hi,

    thanks for all the replies

    I have tried my code again on my own device with a msp430f5528 and now the code works fine.

    It seems that on both previous launchpads the p.4.,1 and 4.2 are dead. No clue why as they were brand new launchpads.   Could it be that I somehow destroyed those pins when using 1 as I2C slave and one as I2C Master, the only  thing I can image is that I accidentally pulled those pins up to 5V . but I cannot see how that destroyed those pins, or even if if that really happened.  

  • If you have e.g. a 1k pull-up to 5V and the MSP is not powered, then you’ll have 5V across 1k to the port pin, the port pin’s clamp diode and VCC. This means, 5mA will flow through the clamp diode which will fry the diode and either break it open (so the 5V will destroy the port logic) or short (which will tie the port pin to VCC).

**Attention** This is a public forum