CAN error flags usage

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

CAN error flags usage

1,270 Views
canbazonur
Contributor II

Hello,

I am looking into can.h file that is in can_fd.loopback example. _can_flags status can be seen by calling CAN_GetStatusFlags(CAN_Type *base) function but there is no info how to reach _can_error_flags registers. How can I do it ? Which function should be used ?

pastedImage_1.png

Thanks and Regards.

Anıl Onur.

Labels (3)
Tags (2)
0 Kudos
5 Replies

958 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Anil Onur Canbaz,

  Please check the user manual protocol status register:

pastedImage_1.png

You can find bit2:0 is just your _can_error_flags, so when you use the CAN_GetStatusFlags

__STATIC_INLINE uint32_t CAN_GetStatusFlags(CAN_Type *base)
{
    return base->PSR;
}

get the PSR register, you can check bit2:0 is which one, then you can know which error happens.

There no API about it, because it is very simple, you can write the code by yourself to check it.

Wish it helps you!


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

958 Views
canbazonur
Contributor II

Hello Kerry,

Thanks for comment.

I could not reach the correct value of controller directly from these registers. As you can see from the log file, CAN-FD frame has been transmitting from the card but can_status_act shows that the node is 'idle' status. Apart from this, I noticed err_can_error_flag (LEC) does not show 'Ack Error' state for other use-case. I am happy to hear some comments about this behavior. You can see how I configured the mask configuration in below.

Thanks and Regards.

pastedImage_2.png

pastedImage_1.png

0 Kudos

958 Views
黎明孟
Contributor II

Hi, i have try the CAN-FD demo, but error frames occured; Can you send your demo to me for test? I see your data log is correctly, Thanks!

My Email: 08-meng@163.com

0 Kudos

958 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi Anil Onur Canbaz,

    You can remove your another CAN node, then debug your LPC54618 CAN code, and check the PSR register directly, check whether the LEC have the error code, it should have the error code, please test it again.

   Any updated information, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

958 Views
canbazonur
Contributor II

Hi Kerry,

I had a chance to test CAN-FD node in alone condition. I noticed that when you test the CAN-FD node in alone, 'can_status_act' counter works. LEC register always shows 0x07 value, however I am waiting 'ACK' error since transmitting node is alone ECU in line.

Another question why 'can_status_act' register does not work in full communication with other CAN-FD nodes.

I am avaliable for further analyze proposal.

Regards.

Onur.

0 Kudos