Hello
thank you so much for your reply. I'd like to answer your first question which I quoted here "so from MeasurementStartPoint,jpg I see 0x714 message is received, after cca 150us 0x5FC0 is sent on SPI SOUT, is this frame equivalent to TLE9261_Write(0x40,0x5F) used in code?"
yes , it is equivalent to TLE9261_Write(0x40,0x5F) used in code.
For the measurement stop point, I introduced another 2 TLE9261_Write(0x40,0x5F) function in my code, you can see them in attached picture named 'Monitor point', I also post my code here:
bl_Error_t Can_Write(bl_CanHandle_t handle, const bl_Buffer_t *buffer, bl_Size_t size)
{
bl_Error_t ret = BL_ERR_NOT_OK;
uint32_t Can_ID = 0x0;
uint8_t Tx_handle = 0;
uint8_t dlc;
CAN_message_t msg_tx;
dlc = Can__SizeToDlc(size);
if (handle > CAN_TXHANDLE_NUM)
{
return ret;
}
Tx_handle = g_CanTxHandleCfg[handle].controller;
if (gs_CanControllerStatus[Tx_handle] != CAN_STATUS_IDLE)
{
ret = BL_ERR_CAN_BUSY;
return ret;
}
Can_ID = g_CanTxHandleCfg[handle].id << 18;
do
{
for (uint8_t i = 0; i < CAN_MAX_NUMBER_OF_CONTROLLER; i++)
{
if (gs_CanControllerCfg[i].usage == CAN_CONTROLLER_UNUSED)
{
continue;
}
if ( (Tx_handle == gs_CanControllerCfg[i].phyId)
&& (CAN_STATUS_IDLE == gs_CanControllerStatus[i]))
{
msg_tx.id = Can_ID;
Can__CopyData(msg_tx.data.bytes,buffer,size);
msg_tx.length = dlc;
TLE9261_Write(0x40, 0x5F);/*Monitor Point 1*/
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 17] = SWAP_UINT32(msg_tx.data.longs[15]);//((uint32_t)buffer[60]) << 24 | ((uint32_t)buffer[61]) << 16 | ((uint32_t)buffer[62]) << 8 | ((uint32_t)buffer[63]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 16] = SWAP_UINT32(msg_tx.data.longs[14]);//((uint32_t)buffer[56]) << 24 | ((uint32_t)buffer[57]) << 16 | ((uint32_t)buffer[58]) << 8 | ((uint32_t)buffer[59]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 15] = SWAP_UINT32(msg_tx.data.longs[13]);//((uint32_t)buffer[52]) << 24 | ((uint32_t)buffer[53]) << 16 | ((uint32_t)buffer[53]) << 8 | ((uint32_t)buffer[55]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 14] = SWAP_UINT32(msg_tx.data.longs[12]);//((uint32_t)buffer[48]) << 24 | ((uint32_t)buffer[49]) << 16 | ((uint32_t)buffer[50]) << 8 | ((uint32_t)buffer[51]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 13] = SWAP_UINT32(msg_tx.data.longs[11]);//((uint32_t)buffer[44]) << 24 | ((uint32_t)buffer[45]) << 16 | ((uint32_t)buffer[46]) << 8 | ((uint32_t)buffer[47]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 12] = SWAP_UINT32(msg_tx.data.longs[10]);//((uint32_t)buffer[40]) << 24 | ((uint32_t)buffer[41]) << 16 | ((uint32_t)buffer[42]) << 8 | ((uint32_t)buffer[43]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 11] = SWAP_UINT32(msg_tx.data.longs[9]);//((uint32_t)buffer[36]) << 24 | ((uint32_t)buffer[37]) << 16 | ((uint32_t)buffer[38]) << 8 | ((uint32_t)buffer[39]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 10] = SWAP_UINT32(msg_tx.data.longs[8]);//((uint32_t)buffer[32]) << 24 | ((uint32_t)buffer[33]) << 16 | ((uint32_t)buffer[34]) << 8 | ((uint32_t)buffer[35]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 9] = SWAP_UINT32(msg_tx.data.longs[7]);//((uint32_t)buffer[28]) << 24 | ((uint32_t)buffer[29]) << 16 | ((uint32_t)buffer[30]) << 8 | ((uint32_t)buffer[31]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 8] = SWAP_UINT32(msg_tx.data.longs[6]);//((uint32_t)buffer[24]) << 24 | ((uint32_t)buffer[25]) << 16 | ((uint32_t)buffer[26]) << 8 | ((uint32_t)buffer[27]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 7] = SWAP_UINT32(msg_tx.data.longs[5]);//((uint32_t)buffer[20]) << 24 | ((uint32_t)buffer[21]) << 16 | ((uint32_t)buffer[22]) << 8 | ((uint32_t)buffer[23]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 6] = SWAP_UINT32(msg_tx.data.longs[4]);//((uint32_t)buffer[16]) << 24 | ((uint32_t)buffer[17]) << 16 | ((uint32_t)buffer[18]) << 8 | ((uint32_t)buffer[19]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 5] = SWAP_UINT32(msg_tx.data.longs[3]);//((uint32_t)buffer[12]) << 24 | ((uint32_t)buffer[13]) << 16 | ((uint32_t)buffer[14]) << 8 | ((uint32_t)buffer[15]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 4] = SWAP_UINT32(msg_tx.data.longs[2]);//((uint32_t)buffer[8]) << 24 | ((uint32_t)buffer[9]) << 16 | ((uint32_t)buffer[10]) << 8 | ((uint32_t)buffer[11]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 3] = SWAP_UINT32(msg_tx.data.longs[1]);//((uint32_t)buffer[4]) << 24 | ((uint32_t)buffer[5]) << 16 | ((uint32_t)buffer[6]) << 8 | ((uint32_t)buffer[7]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 2] = SWAP_UINT32(msg_tx.data.longs[0]);//((uint32_t)buffer[0]) << 24 | ((uint32_t)buffer[1]) << 16 | ((uint32_t)buffer[2]) << 8 | ((uint32_t)buffer[3]);
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 1] = Can_ID; /* MB8 word 1: Tx msg with given ID */
TLE9261_Write(0x40, 0x5F);/*Monitor Point 2*/
S32K_CAN(Tx_handle).RAMn[CAN_USED_HRH_NUM*CAN_MSG_BUF_SIZE + 0] = CAN_RAMn_EDL(1) /* EDL=1 CAN FD format frame*/
|CAN_RAMn_BRS(1) /* BRS=1: Bit rate is switched inside msg */
|CAN_RAMn_ESI(0) /* ESI=0: ??? */
|CAN_RAMn_CODE(CAN_TX_MB_CODE_TRANS) /* CODE=0xC: Activate msg buf to transmit */
|CAN_RAMn_SRR(0) /* SRR=1 Tx frame (not req'd for std ID) */
|CAN_RAMn_IDE(0) /* IDE=0: Standard ID */
|CAN_RAMn_RTR(0) /* RTR = 0: data, not remote tx request frame*/
|CAN_RAMn_DLC(dlc); /* DLC=x; 1,2,3,4,5,6,7,8, 9-12,10-16, 11-20, 12-24, 13-32, 14-48, 15-64bytes */
TLE9261_Write(0x40, 0x5F);/*Monitor Point 3*/
// while (!(S32K_CAN(Tx_handle).IFLAG1 & 0x100)) {}; /* Wait for CAN 0 MB 8 flag */
// S32K_CAN(Tx_handle).IFLAG1 = 0x00000100; /* Clear CAN 0 MB 8 flag without clearing others*/
gs_CanControllerStatus[i] = CAN_STATUS_TRANSMITTING;
ret = BL_ERR_OK;
}
}
} while(0);
return ret;
}
The 1st monitor point is put before set ID for MB, 2nd monitor code is put just before update the code of MB to 0xC(transmit), 3rd monitor point is put just after update the code of MB to transmit.
I debug the code, and find the 2 phenomenons which I will describe as below:
1. Firstly I send a diag request service to read DID, test send 0x22 F1 87 on bus, but ECU not response. From the attached picture named 'Received request but no response' you can see ECU actually received the request message, and it is going to send the response and update the MB(monitor point 1 ,2 and 3 are captured in this snapshot), but no response message was monitored on CAN Tx PIN;
2. Then I monitor the ESR1, IFALG1 and RAM registor, and find that the code of transmit MB has been updated to 0xC(transmit) successfully, and the CAN bus is IDLE and no other error in ESR1 registor, But the message was not transmitted on CANTx, it seems flexCAN0 not ready to start to transmit which cause the message was stuck in SMB;
3. Thirdly I try to send another diag request, so I send 0x10 01 service, then ECU response rapidly with 0x62 F1 87.... you can see in the attached picture named 'New received request triggered the transmit of the reponse of last request.'. the message was transmitted before the code of monitor point 1, 2, 3, was executed. So It seems a newly request message trigger ECU to transmit the response of last request!!! which seems so unreasonable..
I really need your kind support to figure out this issue, thanks a lot.
Kofi Wang