cancel
Showing results for 
Search instead for 
Did you mean: 

spc560p can abort mechanism

wang mengmeng
Associate II
Posted on May 10, 2018 at 13:14

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ï¼�

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
5 REPLIES 5
Erwan YVIN
ST Employee
Posted on May 15, 2018 at 11:06

Hello Wang ,

I have sent your question to an expert.

          Best regards

                       Erwan

procolo
Senior
Posted on May 16, 2018 at 10:54

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, automatic

recovering from Bus Off state occurs according to the CAN Specification 2.0B. If the bit is

asserted, automatic recovering from Bus Off is disabled and the module remains in Bus Off state

until the bit is negated by the user. If the negation occurs before 128 sequences of 11 recessive

bits are detected on the CAN bus, then Bus Off recovery happens as if the BOFF_REC bit had

never 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 be

effective the next time the module enters Bus Off. If BOFF_REC was negated when the module

entered 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

Posted on May 17, 2018 at 08:13

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 the

bus. Hence, Tx_Err_Counter is reset to 0 and counts in a manner where the internal

counter counts 11 such bits and then wraps around while incrementing the

Tx_Err_Counter. When Tx_Err_Counter reaches the value of 128, the FLT_CONF field

in the Error and Status Register is updated to be ‘Error Active’ and both error counters

are reset to zero. At any instance of dominant bit following a stream of less than 11

consecutive recessive bits, the internal counter resets itself to zero without affecting the

Tx_Err_Counter value

So 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

procolo
Senior
Posted on May 18, 2018 at 10:36

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

Posted on May 24, 2018 at 03:14

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? 0690X00000602W3QAI.bmp