Part Number: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 */
Ben Qin:
你好,可以详细描述下哪里不懂吗?是某个函数还是?
,
measure CHANG:
您好,我不知道这个函数在传输什么数据
,
Ben Qin:
可能是与主机的USS Design Center GUI交互。
,
measure CHANG:
请问这个时钟是在对什么的定时呀?
,
Ben Qin:
此功能可用于设置 USS 测量之间的定时器周期。您可以在 ussSWLib.h 中找到定义信息。
,
measure CHANG:
请问什么叫做USS测量之间的定时器周期?是指发送一串激励脉冲到开始采样之间的时间吗?
,
measure CHANG:
还想请问下,这个measurePeriod的时钟初始化是不是commonTimerConfigureTimer这个函数?
,
measure CHANG:
还有这里,请问为什么又要配置时钟,不太能理解,请解释以下
,
Ben Qin:
measure CHANG 说:请问什么叫做USS测量之间的定时器周期
就是USS测量的周期。
,
measure CHANG:
USS测量的周期可以在图里指一下吗?还有时钟的部分,如果这个图能表示,可以也指一下吗?
,
Ben Qin:
measure CHANG 说:还想请问下,这个measurePeriod的时钟初始化是不是commonTimerConfigureTimer这个函数?
measurePeriod 不是 commonTimerConfigureTimer 的函数。
measure CHANG 说:还有这里,请问为什么又要配置时钟,不太能理解,请解释以下
你是问为什么要在commonTimerGenerateLowPowerDelay函数中配置定时器?
,
Ben Qin:
measure CHANG 说:还有时钟的部分,如果这个图能表示,可以也指一下吗
哪一部分的时钟?
,
measure CHANG:
USS_configAppTimerPeriod()函数是对USS测量之间的定时,请问USS测量之间的定时是指图中的哪一段?
在对USS进行初始化时,有一段对时钟的初始化函数commonTimerConfigureTimer,请问这里配置的时钟是给谁用的?
commonTimerGenerateLowPowerDelay函数所用的时钟是在哪里初始化的,有什么作用?
总之,我对这个例程所用的时钟不太清楚,请详细解释一下
,
Ben Qin:
好的,我已向工程师那边跟进。
,
measure CHANG:
您好,请问怎么样了?
,
Ben Qin:
你好,USS_configAppTimerPeriod() 如下图所示:
定时器功能不控制测量序列。对于测量序列,请参考user guide第21.4章节。 https://www.ti.com/lit/ug/slau367p/slau367p.pdf
Best Regards,
Ben
,
measure CHANG:
measure CHANG 说:
在对USS进行初始化时,有一段对时钟的初始化函数commonTimerConfigureTimer,请问这里配置的时钟是给谁用的?
commonTimerGenerateLowPowerDelay函数所用的时钟是在哪里初始化的,有什么作用?
谢谢您的回答,请问这里的两个问题,也回答以下吧,谢谢
,
Ben Qin:
commonTimerConfigureTimer 仅在 ussSwLibMeasurement.c 中调用,用于检查 LFXT 振荡故障标志。
commonTimerGenerateLowPowerDelay在ussSWLibCommonTimer.h中编码。它用于在MCU保持LPM模式的情况下延迟一段时间。