Part Number: MSP430FR2476
Other Parts Discussed in Thread: TMP102
So, I was able to fix a first issue on the I2C, and what I want to obtain as a first step is to see in a while loop
the transmission of a dummy byte on my logic analyser. My current code is the following
#include "driverlib.h"
#include <stdio.h>
#include <string.h>
/* Global Defines */
#define CS_MCLK_DESIRED_FREQUENCY_IN_KHZ 16000 /**< Target frequency for MCLK in kHz */
#define CS_MCLK_FLLREF_RATIO 488 /**< MCLK/FLLRef Ratio */
int main(void)
{
volatile uint32_t i;
uint8_t transmitData;
WDT_A_hold(WDT_A_BASE);
GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P3, GPIO_PIN2 | GPIO_PIN6);
GPIO_setAsPeripheralModuleFunctionInputPin(
GPIO_PORT_P3,
GPIO_PIN2 + GPIO_PIN6,
GPIO_PRIMARY_MODULE_FUNCTION
);
/*
* Disable the GPIO power-on default high-impedance mode to activate
* previously configured port settings
*/
PMM_unlockLPM5();
//Initialize transmit data packet
transmitData = 0x01;
//Initialize Master
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_B1_BASE, ¶m);
//Specify slave address
EUSCI_B_I2C_setSlaveAddress(EUSCI_B1_BASE,
0x48
);
//Set in transmit 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);
while(1)
{
EUSCI_B_I2C_masterSendSingleByte(EUSCI_B1_BASE,
0xAA //Send MSB of the address first
);
for(i=100000; i>0; i--);
}
}
would normally expect to see on the logic analyser a sequence of transmission attempts to address 0x48, all ending with a NAK since the peripheral is not connected.
What I get is a single transmission as in the screen capture below
and then the SCL line stays low.
By debugging the code, I found out that the program gets stuck in the eusci_b_i2c.c file, at line 192 at the following instruction of function EUSCI_B_I2C_masterSendSingleByte()
//Poll for transmit interrupt flag.
while (!(HWREG16(baseAddress + OFS_UCBxIFG) & UCTXIFG)) ;
Is this happening because no peripheral is connected? How to solve this? thanks in advance!

