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.

MSP430FR2475: I2c Always busy

Part Number: MSP430FR2475

Hi, Busy bit in UCBxSTATW is always set after I enable I2c with "EUSCI_B_I2C_enable(EUSCI_B1_BASE);" Am i doing something wrong?

I have 10k pull up resitor on SDA and SCL , I measured them and both are high.

Also tried to send a STOP  by "HWREG16(EUSCI_B1_BASE + OFS_UCBxCTLW0) |= UCTXSTP;"

void Inicializacion(void)
{
    WDT_A_hold(WDT_A_BASE);
    //Configuracion DCO con FLL, 12MHz    /////////////////////////////
    //Variable to store current Clock values
    uint32_t clockValue = 0;
    // Set DCO FLL reference = REFO
    CS_initClockSignal(CS_FLLREF,CS_REFOCLK_SELECT,CS_CLOCK_DIVIDER_1);
    // Set ACLK = REFO
    CS_initClockSignal(CS_ACLK,CS_REFOCLK_SELECT,CS_CLOCK_DIVIDER_1);
    // Set Ratio and Desired MCLK Frequency  and initialize DCO
    CS_initFLLSettle(CS_MCLK_DESIRED_FREQUENCY_IN_KHZ,CS_MCLK_FLLREF_RATIO);//12mhz


    do {
      // If it still can't clear the oscillator fault flags after the timeout,
      // trap and wait here.
        clockValue = CS_clearAllOscFlagsWithTimeout(1000);
    } while(clockValue != 0);
    //clockValue = CS_getSMCLK ();//debug

    GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, I2CSCL, GPIO_PRIMARY_MODULE_FUNCTION);
   GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P4, I2CSDA, GPIO_PRIMARY_MODULE_FUNCTION);


    PMM_unlockLPM5();


    //I2C 400kbps///////////////////////////////////////////////////////////////
    EUSCI_B_I2C_initMasterParam param = {0};
    param.selectClockSource = EUSCI_B_I2C_CLOCKSOURCE_SMCLK;
    param.i2cClk = CS_getSMCLK();
    param.dataRate = EUSCI_B_I2C_SET_DATA_RATE_400KBPS;
    param.byteCounterThreshold = 0;
    param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
    //__delay_cycles(500);
    EUSCI_B_I2C_initMaster(EUSCI_B1_BASE, &param);
    //Specify slave address
    EUSCI_B_I2C_setSlaveAddress(EUSCI_B1_BASE, SLAVE_ADDRESS);
    //Set Master in receive mode
    EUSCI_B_I2C_setMode(EUSCI_B1_BASE,EUSCI_B_I2C_TRANSMIT_MODE);
    //Enable I2C Module to start operations
    EUSCI_B_I2C_enable(EUSCI_B1_BASE);

    __bis_SR_register(GIE);               // Enable interrupts

    //init TLC
    while(EUSCI_B_I2C_isBusBusy (EUSCI_B1_BASE));//debug

}

  • To use I2C on the P4 pins, you need to set USCIB1RMP; otherwise they're on P3. [Ref data sheet (SLASEO7B) Table 6-11 and user guide (SLAU445I) Table 1-32]

    I don't see a driverlib function to do this, so just add something like:

    > SYSCFG3 |= USCIB1RMP;   // Point UCB1 at P4 pins, not P3 pins

    [Edit: On a separate topic: If you're really setting MCLK=12MHz, you need to set the FRAM wait states. Based on the driverlib source (framctl.c), this would look something like:

    > FRAMCtl_configureWaitStateControl(FRAMCTL_ACCESS_TIME_CYCLES_1); // NWAITS=1 for 12MHz clock

    ]

  • Now its working! thanks!

**Attention** This is a public forum