Other Parts Discussed in Thread: MSP430FR6989, BOOSTXL-BATPAKMKII
Tool/software: Code Composer Studio
This screen capture shows the sequence of operation o the I2C between the PCF8523 and the TI MCU
Slave address is 0x68 << 1 (D0 for write D1 for Read )
We are reading register control 3 from the PCF 8523
We have write on slave 0x68 the register address to read 0x02 an ACK is replied by device
then we send a Read which is replied with ACK as well, then on the I2c bus we see the content of this register 0xE0 which is consistent with what is expected from the PCF8523 Datasheet.
the NAK at the end of this transfer is the issue. I was expecting to see a ACK at this time.
Could you give some guidance to solve this issue ?
Hi,
Our project, among other modules, uses the I2C Module.
The device we are designing, is using an NXP PCF8523 external RTC.
The hardware connections between the NXP PCF8523 and the Launchpad board have been done as follows:
- P4.1 SCL to SCL PCF8523
- P4.0 SDA to SDA PCF8523
- VCC from PCF8523 to TI Board
- GND from PCF8523 to TI Board
We use the source code based on the supplied example code BOOSTXL-BATPAKMKII_FuelGauge_MSP430FR6989
From this base project we stripped everything that is not I2C related the resulting project is called REPORT_TI.
The main program is as follows
int main(void) {
// Halt the watchdog timer
WDT_A_hold(WDT_A_BASE);
/* Initialization */
GPIO_init();
CS_init();
/* Initialize I2C */
I2C_initGPIO();
I2C_init();
__delay_cycles(800000);
bool res;
char val;
// Read Control Register 1
while(1)
{
I2C_setslave(0x68);
res = I2C_read8(0x0, &val, 1000);
__delay_cycles(8000);
res = I2C_read8(0x2, &val, 1000);
__delay_cycles(8000);
res = res;
}
}
/* Initializes Clock System */
void CS_init() {
// Set PJ.4 and PJ.5 as Secondary Module Function Input, LFXT.
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_PJ,
GPIO_PIN4 + GPIO_PIN5,
GPIO_PRIMARY_MODULE_FUNCTION
);
CS_setExternalClockSource(32768, 0);
// Intializes the XT1 crystal oscillator
CS_turnOnLFXT(CS_LFXT_DRIVE_3);
/* Initializes Clock System DCO = 8MHz */
CS_setDCOFreq(CS_DCORSEL_0, CS_DCOFSEL_6);
CS_initClockSignal(CS_MCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
CS_initClockSignal(CS_SMCLK, CS_DCOCLK_SELECT, CS_CLOCK_DIVIDER_1 );
CS_initClockSignal(CS_ACLK, CS_LFXTCLK_SELECT, CS_CLOCK_DIVIDER_1);
}
/* Initializes GPIO */
void GPIO_init()
{
/* Terminate all GPIO pins to Output LOW to minimize power consumption */
GPIO_setAsOutputPin(GPIO_PORT_PA, GPIO_PIN_ALL16);
GPIO_setAsOutputPin(GPIO_PORT_PB, GPIO_PIN_ALL16);
GPIO_setAsOutputPin(GPIO_PORT_PC, GPIO_PIN_ALL16);
GPIO_setAsOutputPin(GPIO_PORT_PD, GPIO_PIN_ALL16);
GPIO_setAsOutputPin(GPIO_PORT_PE, GPIO_PIN_ALL16);
GPIO_setAsOutputPin(GPIO_PORT_PF, GPIO_PIN_ALL16);
GPIO_setOutputLowOnPin(GPIO_PORT_PA, GPIO_PIN_ALL16);
GPIO_setOutputLowOnPin(GPIO_PORT_PB, GPIO_PIN_ALL16);
GPIO_setOutputLowOnPin(GPIO_PORT_PC, GPIO_PIN_ALL16);
GPIO_setOutputLowOnPin(GPIO_PORT_PD, GPIO_PIN_ALL16);
GPIO_setOutputLowOnPin(GPIO_PORT_PE, GPIO_PIN_ALL16);
GPIO_setOutputLowOnPin(GPIO_PORT_PF, GPIO_PIN_ALL16);
// Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
PMM_unlockLPM5();
}