2018-05-10 04:14 AM
hello guys:
I am using the flexcan module of spc560p, now I want to use the abort mechanism to recover the can bus from busoff state by software instead of by the hardware automaticly,because the hardware recovery is too fast,
So I enabled the AEN bit in the MCR,when I captured the busoff in ESR register,I began to abort the TX MB by set the CS CODE to 09, and then activited the TX MB by set the CS CODE to 08,and then send the message,but there was no message had been sent out,and the can bus was still busoff,there was no waveform in the can bus ,I‘ve seen the manual several times, but I am not clear about how to recover from the busoff state by software?If any of you have the answers,I will be very appreciate�
2018-05-15 02:06 AM
Hello Wang ,
I have sent your question to an expert.
Best regards
Erwan
2018-05-16 01:54 AM
Hello,
I suppose you set BOFF_REC bit in CTRL register to 1 in order to avoid automatically recovery.
Anyway you can use this bit during execution when catching a bus off interrupt as reported below.
Bus Off Recovery Mode
This bit defines how FlexCAN recovers from Bus Off state. If this bit is negated, automaticrecovering from Bus Off state occurs according to the CAN Specification 2.0B. If the bit isasserted, automatic recovering from Bus Off is disabled and the module remains in Bus Off stateuntil the bit is negated by the user. If the negation occurs before 128 sequences of 11 recessivebits are detected on the CAN bus, then Bus Off recovery happens as if the BOFF_REC bit hadnever been asserted. If the negation occurs after 128 sequences of 11 recessive bits occurred,then FlexCAN will resynchronize to the bus by waiting for 11 recessive bits before joining the bus.After negation, the BOFF_REC bit can be re-asserted again during Bus Off, but it will only beeffective the next time the module enters Bus Off. If BOFF_REC was negated when the moduleentered Bus Off, asserting it during Bus Off will not be effective for the current Bus Off recovery.0 Automatic recovering from Bus Off state enabled, according to CAN Spec 2.0 part B.1 Automatic recovering from Bus Off state disabled.Regards,
Procolo
2018-05-17 01:13 AM
Hello
Procolo:
Thanks for your help! I have got the description in the manual, but there is another problem that how can I know that the
128 sequences of 11 recessive bits have been detected, I checked the manual and found the description about the ECR register in busoff state,shown as below:If FlexCAN is in ‘Bus Off’ state, then Tx_Err_Counter is cascaded together with another
internal counter to count the 128th occurrences of 11 consecutive recessive bits on thebus. Hence, Tx_Err_Counter is reset to 0 and counts in a manner where the internalcounter counts 11 such bits and then wraps around while incrementing theTx_Err_Counter. When Tx_Err_Counter reaches the value of 128, the FLT_CONF fieldin the Error and Status Register is updated to be ‘Error Active’ and both error countersare reset to zero. At any instance of dominant bit following a stream of less than 11consecutive recessive bits, the internal counter resets itself to zero without affecting theTx_Err_Counter valueSo I learnt that if I want to recover from the busoff state by software, I need to assert the
BOFF_REC
first, and when the Flexcan enter the busoff state, I need to monitor the Tx_Err_Counter and Rx_Err_Counter, if both of the err counters reset to 0, It can be concluded that the 128th occurrences of 11 consecutive recessive bits have been detected, and all I have to do is set the BOFF_REC
bit to 0. Is that right?
Thanks!
Best regards
mengmeng
2018-05-18 01:36 AM
Hello Mengmeng,
Yes you're right but you should also check FLT_CONF in ESR register which will be set to error active (00)
when can is in bus off the tx counter reaches 128.
Regards,
Procolo
2018-05-23 08:14 PM
Hello procolo?
Actually, I don't quite understand about what you said about the
?
FLT_CONF in ESR register which will be set to error active (00) when can is in bus off the tx counter reaches 128??but I have tried?and yes the FLT_CONF will be set to 00?and the bus is still in busoff state?I was so confused that if it is always happen?how can I conclude that the bus recovers indeed?