Other Parts Discussed in Thread: CC430F6137
Hi All,
I’m working on the eZ430 HW and need to build an I2C Slave protocol from PIN1.6, P1.7 or P1.5.
After looking on the cc430x613x_uscib0_i2c_07.c and the cc430x613x_uscib0_i2c_05.c
It seems that the (CC430F137 HW) USCI_B I2C Mode supplies it on other pins i.e. P2.6 and P2.7.
Is there a way to switch those pins from P2.6 and P2.7 to PIN1.6, P1.7 or P1.5 on that program?
Like the followings?
//******************************************************************************
// CC430F613x Demo - USCI_B0 I2C Slave Rx and Tx 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 reception is demonstrated using the USCI_B0 RX interrupt.
// ACLK = n/a, MCLK = SMCLK = default DCO = ~1.045MHz
//
//
// /|\ /|\
// CC430F6137 10k 10k CC430F6137
// slave | | master
// ----------------- | | -----------------
// -|XIN P1.6/UCB0SDA|<-|----+->|P2.6/UCB0SDA XIN|-
// | | | | | 32kHz
// -|XOUT | | | XOUT|-
// | P1.7/UCB0SCL|<-+------>|P2.7/UCB0SCL |
// | | |
//
// M Morales
// Texas Instruments Inc.
// April 2009
// Built with CCE Version: 3.2.2 and IAR Embedded Workbench Version: 4.11B
//******************************************************************************
#include "cc430x613x.h"
volatile unsigned char RXData;
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop WDT
PMAPPWD = 0x02D52; // Get write-access to port mapping regs
P1MAP6 = PM_UCB0SDA; // Map UCB0SDA output to P1.6
P1MAP7 = PM_UCB0SCL; // Map UCB0SCL output to P1.7
PMAPPWD = 0; // Lock port mapping registers
PMAPPWD = 0; // Lock port mapping registers
P1SEL |= BIT6 + BIT7; // Select P1.6 & P1.7 to I2C function
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
UCB0IE |= UCTXIE + UCSTTIE + UCSTPIE; // Enable RX + TX interrupts
while (1)
{
__bis_SR_register(LPM0_bits + GIE); // Enter LPM0, enable interrupts
__no_operation(); // Set breakpoint >>here<< and read
} // RXData
}
// USCI_B0 Data ISR
#pragma vector = USCI_B0_VECTOR
__interrupt void USCI_B0_ISR(void)
{
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
UCB0IFG &= ~UCSTTIFG; // Clear start condition int flag
break;
case 8: // Vector 8: STPIFG
TXData++; // Increment TXData
UCB0IFG &= ~UCSTPIFG; // Clear stop condition int flag
break;
case 10: // Vector 10: RXIFG
RXData = UCB0RXBUF; // Get RX data
__bic_SR_register_on_exit(LPM0_bits); // Exit LPM0
break;
case 12: // Vector 12: TXIFG
UCB0TXBUF = TXData; // TX data
break;
default: break;
}
}
!!!Note I've changed the Ports to P2.6 and P2.7 to P1.6 and P1.7.!!!!
Thanks a lot,
Shimon.