Hi,
I am having a devil of a time getting the I2C for UCB1 to do anything. I scoped the clock and data lines and they are always high. I attempt a start condition during the function below (called in gyroRegisterWrite()) and nothing gets sent. I'm currently at a loss.
I did some reading on the family datasheet for the MSP430F247 and in that datasheet, P5 has two SEL registers. however when I attempted to write to P5SEL2, i get a build error. How am i to access the I2C without the second P5SEL register?
Anyway, my code is below. At this point I am willing to bit bang a I2C solution as well (i've just started looking for one now).
Thanks in advance,
void initGyroscope()
{
// Reconmended I2C Setup (From MSP430x2xx Family Datasheet)
// 1. Set UCSWRST.
// 2. Initalize all USCI registers with UCSWRST = 1 (including UCxCTL1).
// 3. Configure all ports.
// 4. Clear UCSWRST.
// 5. Enable interrupts (optional).
UCB1CTL1 |= UCSWRST; // Software resst for this USCI.
// Configuring Registers.
UCB1CTL0 = (UCMST | UCMODE_3 // Master, I2C mode, Synchronous.
| UCSYNC);
UCB1CTL1 = (UCSSEL_2 // SMCLK, Transmitter, Software reset.
| UCSWRST);
//UCB1BR0 = 0x14; // SMCLK / 20 (400KHz).
UCB1BR0 = 160; // SMCLK / 160 (100KHz)
UCB1BR1 = 0x00;
// Configuring Ports.
P5SEL |= (SDA | SCL); // Enabling special purpose for these pins.
P5DIR |= (SDA | SCL); // Setting pins to output direction.
//P5REN |= (SDA | SCL); // Using the internal resistors as pullups for output.
// Setting Slave Address
UCB1I2CSA = gyroAddress;
UCB1CTL1 &= ~(UCSWRST); // Enabling I2C communication.
UCB1CTL1 |= (UCTR);
gyroRegisterWrite(GYRO_DLPF_FS, GYRO_FS_SEL0 // Turning on the gyro at 1kHz sampling 2000 deg/s max range.
| GYRO_FS_SEL1 | GYRO_DLPF_CFG0);
}