Tool/software:
Hi,
I want to use eUSCI_B1 for both spi and i2c with different pins. But It does not works together. How its solve?
void InitI2C(unsigned char eeprom_i2c_address)
{
SYSCFG3&=~USCIB1RMP;
P3SEL0 |= BIT2 | BIT6; // I2C pins
P3SEL1 &= ~(BIT2 | BIT6);
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
UCB1CTLW0 = UCSWRST; // Enable SW reset
UCB1CTLW0 |= UCMODE_3 | UCMST | UCSSEL__SMCLK | UCSYNC; // I2C master mode, SMCLK
UCB1BRW = 160; // fSCL = SMCLK/160 = ~100kHz
UCB1I2CSA = eeprom_i2c_address; // Slave Address
UCB1CTLW0 &= ~UCSWRST; // Clear SW reset, resume operation
UCB1IE |= UCNACKIE;
}
void Strip_Init() {
//Configure P4.4 for SPI output
SYSCFG3|=USCIB1RMP;
P4SEL0 |= BIT4;
P4SEL1 &= ~BIT4;
// P4SEL1 = (0);
// Initialize SPI module
UCB1CTLW0 |= UCSWRST; // Put SPI module into reset
// Configure SPI settings: clock polarity, clock phase, etc.
UCB1CTLW0 |= UCSYNC | UCCKPL | UCMSB | UCMST | UCSSEL_2 ;
UCB1BRW = 0x03; // Set clock divider
UCB1CTLW0 &= ~UCSWRST; // Release SPI module from reset
}
Thank You
Athulya