Hi,
I'm using the MSP430F5510 and trying to interface with an EEPROM via I2C. I've searched through the forum but I wasn't able to get a definitive answer.
My question is do I need to check for ACK and if so how do I achieve this without interrupts?
The following is the write cycle taken from the EEPROM's datasheet:
This is my code which actually works but I'm not checking for ACK anywhere (at least not explicitly, maybe driverlib is doing so?)
static void init(void) { WDT_A_hold(WDT_A_BASE); UCS_clockSignalInit(UCS_FLLREF, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1); UCS_clockSignalInit(UCS_ACLK, UCS_REFOCLK_SELECT, UCS_CLOCK_DIVIDER_1); UCS_initFLLSettle(8000000 / 1000, 8000000 / 32768); GPIO_setAsPeripheralModuleFunctionOutputPin(GPIO_PORT_P4, GPIO_PIN1 + GPIO_PIN2); } static void eeprom_init(void) { USCI_B_I2C_initMasterParam param = { 0 }; param.dataRate = USCI_B_I2C_SET_DATA_RATE_400KBPS; param.i2cClk = UCS_getSMCLK(); param.selectClockSource = USCI_B_I2C_CLOCKSOURCE_SMCLK; USCI_B_I2C_initMaster(BASE, ¶m); USCI_B_I2C_setSlaveAddress(BASE, SLAVE_ADDRESS); USCI_B_I2C_enable(BASE); } static void eeprom_write(uint16_t address, uint8_t* data, size_t size) { USCI_B_I2C_setMode(BASE, USCI_B_I2C_TRANSMIT_MODE); USCI_B_I2C_masterMultiByteSendStart(BASE, ADDRESS_HIGH(address)); __delay_cycles(DELAY); USCI_B_I2C_masterMultiByteSendNext(BASE, ADDRESS_LOW(address)); __delay_cycles(DELAY); uint8_t i; for (i = 0; i < size; i++) { USCI_B_I2C_masterMultiByteSendNext(BASE, data[i]); __delay_cycles(DELAY); } USCI_B_I2C_masterMultiByteSendStop(BASE); __delay_cycles(DELAY); }
I've tried to use "while (!(USCI_B_I2C_getInterruptStatus(BASE, USCI_B_I2C_NAK_INTERRUPT)));" but this gets stuck and never returns.
Also BASE is defined as USCI_B1_BASE.
Thanks