Part Number: MSP430FR5969
Other Parts Discussed in Thread: MSP430FR5992
Tool/software: Code Composer Studio
Hi,
I'm trying to send mulitbytes by I2C as master. If it gives you more information, as a slave i'm using pressure sensor MPRLS0025PA00001AB
I was based on the example provided by TI.
The first byte is sent correctly. The other usually too. However, when trying to send byte 3, the STOP condition appears and the UCB0TXIFG flag does not appear, so I cannot send the next byte. I don't know where the STOP condition appears because in the configuration I set it not to be generated automatically.
If you need any explanation just ask me.
It's my code
void main(void)
{
WDT_A_hold(WDT_A_BASE);
CS_setDCOFreq(CS_DCORSEL_0,CS_DCOFSEL_0); //Set DCO frequency to 1MHz
CS_initClockSignal(CS_ACLK,CS_VLOCLK_SELECT,CS_CLOCK_DIVIDER_1); //Set ACLK = VLO with frequency divider of 1
CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); //Set SMCLK = DCO with frequency divider of 1
CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); //Set MCLK = DCO with frequency divider of 1
/*
* Select Port 1
* Set Pin 6, 7 to input Secondary Module Function, (UCB0SIMO/UCB0SDA, UCB0SOMI/UCB0SCL).
*/
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P1,
GPIO_PIN6 + GPIO_PIN7,
GPIO_SECONDARY_MODULE_FUNCTION
);
/*
* Disable the GPIO power-on default high-impedance mode to activate
* previously configured port settings
*/
PMM_unlockLPM5();
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_100KBPS;
param.byteCounterThreshold = 0;
param.autoSTOPGeneration = EUSCI_B_I2C_NO_AUTO_STOP;
EUSCI_B_I2C_initMaster(EUSCI_B0_BASE, ¶m);
//Specify slave address
EUSCI_B_I2C_setSlaveAddress(EUSCI_B0_BASE,
SLAVE_ADDRESS
);
//Set Master in receive mode
EUSCI_B_I2C_setMode(EUSCI_B0_BASE,
EUSCI_B_I2C_TRANSMIT_MODE
);
//Enable I2C Module to start operations
EUSCI_B_I2C_enable(EUSCI_B0_BASE);
EUSCI_B_I2C_clearInterrupt(EUSCI_B0_BASE,
EUSCI_B_I2C_NAK_INTERRUPT
);
//Enable master Receive interrupt
EUSCI_B_I2C_enableInterrupt(EUSCI_B0_BASE,
EUSCI_B_I2C_NAK_INTERRUPT
);
while(1)
{
while (EUSCI_B_I2C_SENDING_STOP == EUSCI_B_I2C_masterIsStopSent
(EUSCI_B0_BASE));
EUSCI_B_I2C_masterSendMultiByteStart(EUSCI_B0_BASE,
0x30);
EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B0_BASE, 0xAA);
EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B0_BASE, 0x00);
EUSCI_B_I2C_masterSendMultiByteNext(EUSCI_B0_BASE, 0x00);
EUSCI_B_I2C_masterSendMultiByteStop(EUSCI_B0_BASE);
__delay_cycles(50);
}
}