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.

MSP430FR5969: I2C stuck in a while loop after address sent

Part Number: MSP430FR5969

Hello, 

Same issue here on FR5969 without solution transmitting the correct slave address. 

I am trying to send data to an OLED display 126x64 0.96" but I can't get a reply from it.

I am wondering if this can be an issue with address sending from MCU since the display works on another MCU.

However, on the oscilloscope I can see that address is sent, but 8 bit data won't follow.

I get stuck in the same loop: while (!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ;

Is there anything I can do to bypass the acknowledgement bit from the slave? 

Here is my complete code:

#include "driverlib.h" 
#include "stdio.h"
#include "stdlib.h"
#include "string.h"

#define Slave_Address 0x78

void main (void)
{

WDT_A_hold(WDT_A_BASE);

PM5CTL0 &= ~LOCKLPM5;

CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_3);
CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1); 
CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_2); 

GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
GPIO_PIN6 + GPIO_PIN7,
GPIO_SECONDARY_MODULE_FUNCTION );

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 = 1;
param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
EUSCI_B_I2C_initMaster(EUSCI_B0_BASE, &param);


EUSCI_B_I2C_setSlaveAddress(EUSCI_B0_BASE, Slave_Address); // INDIRIZZO DELLO SLAVE

EUSCI_B_I2C_setMode(EUSCI_B0_BASE, EUSCI_B_I2C_TRANSMIT_MODE); // DEFINISCO uC COME MASTER IN TRASMISSIONE

EUSCI_B_I2C_enable(EUSCI_B0_BASE); // ABILITO LA I2C


GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); //LED2

uint8_t I2C_msg = 0xAA;

GPIO_setOutputHighOnPin (GPIO_PORT_P1, GPIO_PIN0); // ALZO IL PIN SUL LED

while (1)
{

EUSCI_B_I2C_masterSendSingleByte(EUSCI_B0_BASE, I2C_msg);

}
} 

  • The driverlib (polled) I2C functions don't generally check for NACK, so you would see this symptom if you got one.

    My I2C OLED (from Adafruit, I think) is at address 0x3C, not 0x78.

  • Hello Bruce, Thanks for your answer. 

    In the family user guide I ca see that I2C Master MCU awaits for a NACK after the address was sent, then sends the data. My I2C OLED is of an unknown brand and I can't get enough documentation for it, I only have some libraries and the I2C address. However it works on an MCU from other brands.

    On the oscilloscope I see that the correct address is sent, but no data is following it, SCL goes low and the function stucks in the while loop.
    My guessing is if I could send data from the MCU also without NACK. Is there a way to bypass that? 

  • Did you try using address 0x3C? I have a few "mystery brand" I2C OLEDs (same series, different sizes) and they also respond at address 0x3C.

    My hypothesis is that someone gave you the SLA byte, rather than the I2C address, since (0x3C << 1) == 0x78.

**Attention** This is a public forum