Hi,
I hope this message finds you well. I believe I have identified the root cause of the issue I encountered with the LIN timeout management configuration.
In the EB_Treos28 configuration, the LInResponseTimeout is set to 14. This value represents 1.4 times the bit transmission time, specifically calculated as (14/10)∗bit time(14/10)∗bit time. With a baud rate of 19200 bps, the corresponding time for generating this configuration is calculated as 1.4∗52.08 μs=73 μs1.4∗52.08μs=73μs.
Here is an excerpt of the relevant configuration code:
#ifdef LPUART_LIN_IP_START_TIMER_NOTIFICATION
2292U, /*!< HeaderTimeoutValue in microseconds */
73U, /*!< ResponseTimeoutValue in microseconds for 1 byte */
#endif
In the function Lpuart_Lin_Ip_MasterRxPidByteProcess(const uint8 Instance, const uint8 Data), I noticed the following logic:
else if (LinCurrentState->RxSize > 0u)
{
#if (LPUART_LIN_IP_FRAME_TIMEOUT_DISABLE == STD_OFF)
#ifdef LPUART_LIN_IP_START_TIMER_NOTIFICATION
LinCurrentState->TimerCounting = TRUE;
/* Call notification to start timer for Lpuart instance and configure timeout value. The Master node will receive Response frame */
LPUART_LIN_IP_START_TIMER_NOTIFICATION(Instance, UserConfig->ResponseTimeoutValue * (uint32)(LinCurrentState->RxSize));
#endif
#endif /* (LPUART_LIN_IP_FRAME_TIMEOUT_DISABLE == STD_OFF) */
LinCurrentState->CurrentNodeState = LPUART_LIN_IP_NODE_STATE_RECV_DATA;
}
The timer is initially set for 73 μs∗9 bytes=657 μs73μs∗9bytes=657μs. After this point, the LIN driver state transitions to LPUART_LIN_IP_NODE_STATE_RECV_DATA, where it waits for the slave's data response. However, I originally set the timer to account for 657 , \mu s for the response time of the 9 bytes, which is clearly incorrect. The actual timeout management should be 73 μs∗9 bytes∗8 bits=5256 μs73μs∗9bytes∗8bits=5256μs.
To address this, I propose modifying the LPUART_LIN_IP_START_TIMER_NOTIFICATION callback function as follows:
void LinLpuartStart(uint8 Instance, uint32 MicroSeconds)
{
(void)Instance;
(void)MicroSeconds;
uint32 count_down = 0U;
count_down = MicroSeconds * 40U * 8U;
pit_data.swtich_notificatio_cnt +=1; /* The Start notification shall be called many times which depends on the times of sending frames */
Pit_Ip_StartChannel(0, 0, count_down);
}
BR,
dongxun