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.

Can I use SDA (I2C data) and SCL (I2C clock) on different pins?

Other Parts Discussed in Thread: MSP430F5172

I am working on the MSP430F5172.  I would like to use all of the analog input pins and I2C.  Unfortunately, PM_UCA0SDA and PM_UCB0SCL are located on the same pins as A4 (analog input 4) and A5 (analog input 5). 

 

Is there a way to use SDA (I2C data) and SCL (I2C clock) on different pins?  For example, pins 23 (P3.0) and 24 (P3.1).

  • Hi Michelle,

    Yes, you can map the SDA and SCL functions to P1.x, P2.x, or P3.x using the port mapping controller.  For example:

       PMAPPWD = PMAPPW;  // unlock PMAP module

       // P3MAP0 = PM_UCB0SDA;  // see P3MAP01 statement below.

       // P3MAP1 = PM_UCB0SCL;  // see P3MAP01 statement below.

       P3MAP01 = PM_UCB0SDA | (PM_UCB0SCL << 8);  // shortcut for both statements above.

       PMAPPWD = 0;  // lock PMAP module

       P3SEL |= BIT1 | BIT0;  // give control of P3.0 and P3.1 to the PMAP module

    This code assigns the SDA function to P3.0 and the SCL function to P3.1.  You should configure USCI_B for I2C operation first.

    It's best to perform these PMAP configuration with interrupts masked since the PMAP module has very little patience waiting for you to finish the configuration.  (32 instruction fetches.)

    Jeff

  • Thank you so much for you help.  Your code works.

**Attention** This is a public forum