Right so everyones on the same page that wants to tinker.. The reference manual can be found here (Its already uploaded on this site):
https://www.pjrc.com/teensy/K20P64M72SF1RM.pdf
Page 38 and 39 are the headings.
And pages 1039 through to 1114 cover everything to know about the can implementation.
Right... soooo... error sections.....
44.3.8 Error Counter (CANx_ECR)
44.3.9 Error and Status 1 register (CANx_ESR1).
44.3.13 Error and Status 2 register (CANx_ESR2)
Page 1042 acknowledges something interesting as well.. this feature:
"SYNC bit status to inform that the module is synchronous with CAN bus"
This could also be handy for alot to indicate if they have their CAN timing correct.
Sooooo... a quick hack together in the flex library:
// -------------------------------------------------------------
uint8_t FlexCAN::ErrorCounter(bool RXorTX)
{
if (RXorTX == 0){return (FLEXCAN0_ECR >> 8);}//shift 8 for RX
else {return (FLEXCAN0_ECR);}
}
// -------------------------------------------------------------
uint32_t FlexCAN::ErrorReport(void)
{
return (FLEXCAN0_ESR1);
}
Also need to add in the header for both functions.
Error count grabs the RX or TX error counts. While testing, I see that my RX has 0 RX issues.. but my TX constantly increases (Gets to 128 then resets as per the reference manual).
For the first two WRITE attempts, I get this:
Write1
CAN RX Error Count: 0
CAN TX Error Count: 57
Error Status: 100000000110110
Write2
CAN RX Error Count: 0
CAN TX Error Count: 111
Error Status: 100001000110110
Only difference is bit 9 which is TXWRN which means repetitive errors during message transmission have occured.
Bit 4 and 5 indicate the Fault confinement State where we can have the following conditions:
00 Error Active
01 Error Passive
1x Bus Off
Soooo... since its 11.. means I have both Error Passive and Bus Off state.
Bus Off state prevents me from writing... but still continues to allow reading. (Sound familiar!!???!!).
Ill keep on tinkering....