ST意法半导体
直播中

赖治添

7年用户 212经验值
私信 关注
[问答]

spc560p怎么使用中止机制

你好伙计们
我正在使用spc560p的flexcan模块,现在我想使用中止机制通过软件而不是硬件自动从busoff状态恢复can总线,因为硬件恢复太快了。
因此,当我捕获ESR寄存器中的总线时,我启用了MCR中的AEN位。我通过将CS CODE设置为09开始中止TX MB,然后通过将CS CODE设置为08来激活TX MB,然后发送消息,但是没有消息已被发送出去了,而且公共汽车仍然是公共汽车,但公共汽车上没有波形 - 我已经看过几次这样的手册了但是我不清楚如何通过软件从公交状态中恢复过来 - 如果你们中有人有答案的话,我会非常感谢

以上来自于谷歌翻译


以下为原文




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

回帖(5)

刘鑫

2018-11-12 10:44:37
你好王,
我已将您的问题发送给专家。
 最好的祝福
 二万

以上来自于谷歌翻译


以下为原文




Hello Wang ,
I have sent your question to an expert.
          Best regards
                       Erwan
举报

孙灿

2018-11-12 11:00:43
你好,
我想你将CTRL寄存器中的BOFF_REC位设置为1以避免自动恢复。
无论如何,您可以在执行期间使用此位来捕获总线关闭中断,如下所述。
总线关闭恢复模式
 
此位定义FlexCAN如何从总线关闭状态恢复。如果该位被否定,则自动
根据CAN规范2.0B,从总线关闭状态恢复。如果是的话
断言,从总线关闭自动恢复被禁用,模块保持在总线关闭状态
直到该位被用户否定。如果否定发生在11个隐性的128个序列之前
在CAN总线上检测到位,然后发生总线关闭恢复,就像BOFF_REC位一样
从未被断言过。如果在发生了11个隐性位的128个序列之后发生否定,
然后,FlexCAN将在加入总线之前等待11个隐性位,从而重新同步到总线。
在否定之后,BOFF_REC位可以在总线关闭期间再次重新置位,但它只会是
下次模块进入总线关闭时生效。如果BOFF_REC在模块时被否定
进入总线关闭状态,在总线关闭期间置位它将对当前的总线关闭恢复无效。
0根据CAN Spec 2.0 B部分,从总线关闭状态启用自动恢复。
1从Bus Off状态自动恢复禁用.Regards,
Procolo

以上来自于谷歌翻译


以下为原文




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
举报

赖治添

2018-11-12 11:17:09
你好
Procolo:
谢谢你的帮助!我在手册中有说明,但还有另一个问题,我怎么知道
 
检测到128个11个隐性位的序列,我检查了手册并找到了关于处于总线状态的ECR寄存器的描述,如下所示:
如果FlexCAN处于“关闭”状态,则Tx_Err_Counter与另一个级联
 
内部计数器计数第11次连续隐性位的第128次出现
总线。因此,Tx_Err_Counter被重置为0并以内部的方式计数
计数器计数11个这样的位,然后在递增时包围
Tx_Err_Counter。当Tx_Err_Counter达到128的值时,FLT_CONF字段
在错误和状态寄存器中更新为“错误激活”和两个错误计数器
重置为零。在小于11的流之后的任何显性位的实例
连续隐性位,内部计数器将自身重置为零而不影响
Tx_Err_Counter值所以我了解到如果我想通过软件从busoff状态恢复,我需要断言
BOFF_REC
 首先,当Flexcan进入总线状态时,我需要监视Tx_Err_Counter和Rx_Err_Counter,如果两个错误计数器都复位为0,则可以得出结论,已经检测到第11次连续隐性位的第128次出现,而且所有I要做的就是设置BOFF_REC
 
 比特到0.是吗?
谢谢!
 最好的祝福
 梦梦

以上来自于谷歌翻译


以下为原文




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
举报

孙灿

2018-11-12 11:33:39
你好蒙蒙,
是的,你是对的,但你也应该检查ESR寄存器中的FLT_CONF,它将被设置为错误激活(00)
当可以在总线关闭时,tx计数器达到128。
问候,
Procolo

以上来自于谷歌翻译


以下为原文




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
举报

更多回帖

发帖
×
20
完善资料,
赚取积分