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.

[参考译文] MSP430FR6043:正在传输什么数据 I2CSLAVE__EUSCI_VECTOR 中断?

Guru**** 2484615 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1231258/msp430fr6043-what-data-is-being-transmitted-i2cslave__eusci_vector-interrupt

器件型号:MSP430FR6043

大家好、

客户有一个问题需要您的帮助:

使用的例程为 MSP430FR6043EVM_USS_Water _Demo、当逐步进入调试功能时、我会跳转到 common->DesignCenter->comm->drivers->i2cslave.c 中的 I2CSLAVE__EUSCI_vector 中断、而且无法了解中断发送的数据。

#pragma vector=I2CSLAVE__EUSCI_VECTOR
__interrupt void I2CSlave_ISR(void)
{
	uint8_t ui8Data;
    uint16_t u16Temp;

	switch (__even_in_range(I2CSLAVE__EUSCI_IV, USCI_I2C_UCTXIFG0))
	{
		case USCI_I2C_UCSTTIFG:
			//
			// Check for the repeated start case.  If this is a repeated start
			// and the previous operation was a write to this device,
			// handle the written (received) data.  If this is a first-time stard,
			// the previous I2C state is eI2CSlaveIsIdle.
			//
			if (g_I2CSlaveStatus == eI2CSlaveIsBeingWrittenTo)
			{
				if (I2CSlave_handleEndOfReceive() == true)
				{
					__bic_SR_register_on_exit(I2CSLAVE__LPMx_bits);
				}
			}

			//
			// Reset the I2C Index to zero to begin the new transaction.
			// Then check the I2C mode (read/write) to determine
			// the transaction mode.
			//
			g_ui16I2CIndex = 0;
			if (EUSCI_B_I2C_getMode(I2CSLAVE__EUSCI_B_PERIPHERAL)
					== EUSCI_B_I2C_TRANSMIT_MODE)
			{
				//
				// If this is a read operation (read from this device),
				// cancel the slave request flag and trigger and active
				// exit to alert the application that the flag has changed.
				//
				g_I2CSlaveStatus = eI2CSlaveIsBeingRead;
				g_bI2CSlaveRequestPending = false;
				__bic_SR_register_on_exit(I2CSLAVE__LPMx_bits);

				//
				// If the driver is set up to send the number of bytes to be read
				// before the rest of the buffer, load the number as the first data byte.
				// Otherwise, load the first byte of the transmit buffer into the peripheral.
				//
				if (g_pI2CSlavePort->bSendReadLengthFirst == true)
				{
					ui8Data = g_ui16I2CLength;
				}
				else
				{
					ui8Data = g_pI2CTransmitBuffer[g_ui16I2CIndex++];
				}
				EUSCI_B_I2C_slavePutData(
						I2CSLAVE__EUSCI_B_PERIPHERAL,
						ui8Data
					);
			}
			else
			{
				//
				// If this is a write operation (write from master to this device),
				// update the status accordingly and continue (no additional action is necessary).
				//
				g_I2CSlaveStatus = eI2CSlaveIsBeingWrittenTo;
			}

			//
			// If the slave timeout feature is enabled, schedule a
			// transaction timeout.
			//
#if (I2CSLAVE__TIMEOUT_ENABLE==true)
			Timer_scheduleDelayedFunction(eTimerDelayedFunction_B);
#endif /* I2CSLAVE__TIMEOUT_ENABLE==true */
			break;

		case USCI_I2C_UCSTPIFG:
			//
			// If the timeout feature is enabled, cancel
			// the transaction timeout as the operation
			// has finished successfully.
			//
#if (I2CSLAVE__TIMEOUT_ENABLE==true)
			Timer_cancelDelayedFunction(eTimerDelayedFunction_B);
#endif /* I2CSLAVE__TIMEOUT_ENABLE==true */


			if (g_I2CSlaveStatus == eI2CSlaveIsBeingWrittenTo)
			{
				//
				// If the operation that is ending was a write to this
				// device, handle the written (received) data, and exit
				// active if the callback function requested it.
				//
				if (I2CSlave_handleEndOfReceive() == true)
				{
					__bic_SR_register_on_exit(I2CSLAVE__LPMx_bits);
				}
			}
			else if (g_I2CSlaveStatus == eI2CSlaveIsBeingRead)
			{
				//
				// If the opreation that is ending was a read from this device,
				// exit active in case a transmit (read) buffer pointer update
				// was pending upon this read.
				//
				__bic_SR_register_on_exit(I2CSLAVE__LPMx_bits);
			}

			//
			// Set new status to idle, as the I2C transaction has stopped.
			//
			g_I2CSlaveStatus = eI2CSlaveIsIdle;
			break;

		case USCI_I2C_UCRXIFG0:
			//
			// Grab the received (written) byte from the I2C peripheral.
			// If there is receive buffer space left, store the received
			// byte in the receive buffer.  Otherwise, discard it and call
			// the error callback fxn if one is registered.
			//
			ui8Data = EUSCI_B_I2C_slaveGetData(I2CSLAVE__EUSCI_B_PERIPHERAL);
			if (g_ui16I2CIndex < g_pI2CSlavePort->ui16ReceiveBufferSize)
			{
				g_pI2CSlavePort->pReceiveBuffer[g_ui16I2CIndex++] = ui8Data;
			}
			else
			{
				if (g_pI2CSlavePort->pvErrorCallback != 0)
				{
					g_pI2CSlavePort->pvErrorCallback(eI2CSlaveReceiveBufferFull);
				}
			}
			break;

		case USCI_I2C_UCTXIFG0:
			//
			// If the transmit index is less than the length, there is still
			// valid data in the buffer.  Load the next byte.
			// Else, there is no valid data left in the buffer, so transmit
			// the invalid byte.
			//
            u16Temp = g_ui16I2CLength;
			if (g_ui16I2CIndex<u16Temp)
			{
				ui8Data = g_pI2CTransmitBuffer[g_ui16I2CIndex++];
			}
			else
			{
				ui8Data = I2CSLAVE__INVALID_BYTE;
				if (g_pI2CSlavePort->pvErrorCallback != 0)
				{
					g_pI2CSlavePort->pvErrorCallback(eI2CSlaveWasReadBeyondTransmitBuffer);
				}
			}
			EUSCI_B_I2C_slavePutData(I2CSLAVE__EUSCI_B_PERIPHERAL, ui8Data);
			break;
	}
}

#endif /* I2CSLAVE__ENABLE==true */

您能帮助检查这个问题吗?

谢谢。此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    它可能会向主机 USS 设计中心 GUI 发送握手信号。  

    此致、

    现金 Hao

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    现金、您好!

    这个时钟的设置计时有什么作用?

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    尊敬的 Ben:

    此函数可用于设置 USS 测量之间的计时器周期。 您可以在 ussSWLib.h 中找到定义信息  

     

    此致、

    现金 Hao

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    现金、您好!

    USS 测量之间的计时器周期是多少? 是发送一列激励脉冲到开始采样的时间吗?

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    它是 USS 测量之间的时长。

    此致、

    现金 Hao

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    现金、您好!

    measurePeriod 的时钟初始化函数是否为 commonTimerConfigureTimer 的函数?

    为什么需要配置时钟?

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    measurePeriod 不是 commonTimerConfigureTimer 的函数。

    为什么需要配置时钟?

    我不完全理解这个问题、您在问为什么需要在 commonTimerGenerateLowPowerDelay 函数中配置计时器?

    此致、

    现金 Hao

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    现金、您好!

    函数 USS_configAppTimerPeriod ()是 USS 测量之间的时间,那么下图所示的时间是在哪一部分?

    在初始化 USS 时、有一个计时器初始化函数 commonTimerConfigureTimer、此计时器的用途是什么?

    在哪里初始化 commonTimerGenerateLowPowerDelay 函数计时器? 此函数的用途是什么?

    无论如何、我对本示例中的时钟感到困惑、请详加阐述。

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

    USS_configAppTimerPeriod() 如下图所示。  

    计时器功能不控制测量序列。 有关测量顺序、请参阅 UG 中的第21.4章"采集序列发生器"。  https://www.ti.com/lit/ug/slau367p/slau367p.pdf

    此致、

    现金 Hao

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    现金、您好!

    在初始化 USS 时、有一个计时器初始化函数 commonTimerConfigureTimer、此计时器的用途是什么?

    在哪里初始化 commonTimerGenerateLowPowerDelay 函数计时器? 这种计时器的用途是什么?

    您可以详细说明这两个问题吗?

    此致、

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好!

     仅在用于检查 LFXT 振荡故障标志的 ussSwLibMeasurement.c 中调用 commonTimerConfigureTimer。

     commonTimerGenerateLowPowerDelay 编码在 ussSWLibCommonTimer.h 中 它用于 在 MCU 保持在 LPM 模式下的一段时间内进行延迟。

    此致、

    现金 Hao