S32K146 CAN Tx: Error and Status 1 register (ESR1)

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

S32K146 CAN Tx: Error and Status 1 register (ESR1)

跳至解决方案
2,891 次查看
john24
Contributor III

Hello,

Our target board is S32K146 based, and we have a general question:

  • In the event of Error and Status 1 register, IDLE (bit 7), is not set (zero), should our firmware still go ahead and invoke 
    FLEXCAN_DRV_ConfigTxMb followed by 
    FLEXCAN_DRV_Send (or
    FLEXCAN_DRV_SendBlocking)?
     
    Thank you.
标记 (2)
0 项奖励
回复
1 解答
2,751 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@john24

I think you have a misunderstanding here. 

The IDLE of ESR1 only indicates that the current CAN bus is in the IDLE state, there is no relationship between the status of IDLE and your call "FLEXCAN_DRV_SendBlocking".

Even if the current CAN BUS is not in the IDLE state, you can still call "FLEXCAN_DRV_SendBlocking", the move-out mechanism iscompleted by FLEXCAN IP layer and does not require you to do anything.

 

After you call FLEXCAN_DRV_SendBlocking you need to call FLEXCAN_DRV_GetTransferStatus to determine whether the sending is completed.

在原帖中查看解决方案

0 项奖励
回复
8 回复数
2,870 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@john24

I'm sorry that I didn't understand your question, maybe you can describle your question in detail in Chinese.

0 项奖励
回复
2,862 次查看
john24
Contributor III

Hi Senlent,

Basically, when reading the S32K RM, we see bit 7 of the ESR1 register documented as:

IDLE

This bit indicates when CAN bus is in IDLE state. See the table in the overall ESR1 register description.
0b - No such occurrence.
1b - CAN bus is now IDLE.

Could you please explain what "0b - No such occurrence" means?

Thank you.

 

0 项奖励
回复
2,822 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@John24

当前CAN bus状态不处于空闲状态

Senlent_0-1708912864965.png

 

0 项奖励
回复
2,808 次查看
john24
Contributor III

Thank you, Senlent, and please feel free to respond in Chinese. I can read it without problems, but to input Chinese would be difficult on my computer here.

So, when the IDLE bit is 0, is it recommended to call any S32K API (e.g. FLEXCAN_DRV_Send, or FLEXCAN_DRV_SendBlocking) in our firmware, to transmit a packet to the CAN bus?

Please let me know. Thanks!

0 项奖励
回复
2,789 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@john24

you can use FLEXCAN_DRV_GetTransferStatus to get the status of the currently used MB to determine whether the reception or transmission was successful.

for example:

Senlent_0-1708998934021.png

This is a routine for CAN interrupt transmission and reception and shows you how to configure the mask, this may be helpful for you to learn the FLEXCAN module.

https://community.nxp.com/t5/S32K-Knowledge-Base/S32K1xx-FlexCAN-Mask-Setting-Demo/ta-p/1519753

 

0 项奖励
回复
2,761 次查看
john24
Contributor III

Hi Senlent,

Our question is actually simple: When FLEXCAN_DRV_GetErrorStatus returns the register ESR1 status with IDLE bit set to 0, can we still call FLEXCAN_DRV_SendBlocking to send a data packet on the CAN bus? Or, we will have to wait until the IDLE bit becomes 1 first?

Thank you!

0 项奖励
回复
2,752 次查看
Senlent
NXP TechSupport
NXP TechSupport

Hi@john24

I think you have a misunderstanding here. 

The IDLE of ESR1 only indicates that the current CAN bus is in the IDLE state, there is no relationship between the status of IDLE and your call "FLEXCAN_DRV_SendBlocking".

Even if the current CAN BUS is not in the IDLE state, you can still call "FLEXCAN_DRV_SendBlocking", the move-out mechanism iscompleted by FLEXCAN IP layer and does not require you to do anything.

 

After you call FLEXCAN_DRV_SendBlocking you need to call FLEXCAN_DRV_GetTransferStatus to determine whether the sending is completed.

0 项奖励
回复
2,723 次查看
john24
Contributor III

Thank you Senlent, for confirming that even if the IDLE bit in ESR1 is indicating the CAN bus not in the idle state, the SDK API calls can still be made in our firmware, to transmit CAN packets.

0 项奖励
回复