是否有重新映射/切换CANTX/CANRX引脚STM32H7 FDCAN模块的过程?
使用 FDCAN 模块(从旧的 BxCAN 外设更新)测试 STM32。 CAN 经典,速率为 500kbps。
我遇到了一个问题,当使用默认的引脚对(在我的例子中为 D0/D1)时,我得到了预期的行为,但是当使用 GPIO 重新映射将引脚切换到辅助选项(B8/B9)时,我得到了奇怪的输出公交车。
我尝试了波特率设置和协议异常等选项。似乎没有什么可以解释这个示波器的输出来自哪里。
我正在使用 HAL 来实现此功能,因此我确信在重新映射时我没有丢失任何寄存器。我已经 DeInit 和 ReInit FDCAN 模块,启动/停止等。似乎没有记录重新映射引脚的“过程”。参考模块的整个 FDCAN 部分没有字母 GPIO。
图片: 黄色为CANTX 0-3V信号(低电平为主)。紫色是 CAN+ 信号,空闲时电压为 2.5V,在显性电压上拉过约 3.5V。这条线上没有其他任何东西,所以我不担心锯齿状。大的初始 CAN“SOF”脉冲对于定时来说是错误的。长隐性是无稽之谈。那么小值 1 位是 500kbps 的正确 2uS 脉冲。更改放入 FDCAN FIFO 的数据没有任何区别,输出始终相同。
Testing out an STM32 with an FDCAN module (updated from the older BxCAN peripheral). CAN Classic at 500kbps.
I am running into an issue that when using the default pair of pins (D0/D1 in my case) I get expected behavior, but when switching the pins to the secondary option (B8/B9) using GPIO remapping, I get strange output on the bus.
I tried baud settings and options like protocol exception. Nothing seems to explain where this scope output is coming from.
I'm using the HAL to get this working, so I'm certain I'm not missing any registers on remapping. I've DeInit and ReInit the FDCAN module, started/stopped, etc. There seems to be no documented "process" for remapping pins. The entire FDCAN section of the reference module doesn't have the letters GPIO.
Picture: Yellow is the CANTX 0-3V signal (low is dominant). Purple is the CAN+ signal that idles at 2.5V and pulls past ~3.5V on a dominant. There is nothing else on this line, so I'm not concerned about the sawtoothing. The large initial CAN "SOF" pulse is wrong for timing. The long recessives are nonsense. Then the small value 1 bits are of the correct 2uS pulses for 500kbps. Changing the data put into the FDCAN FIFO makes no difference, the output is always the same.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决了。
发送此消息后,
FDCAN->CCCR
寄存器中的 INIT 位被设置。错误计数器中有值。指示内部错误。我使用 HAL 来节省时间,但它覆盖了我想要的 GPIO 设置。我会将 FDCAN 的引脚 B8/B9 设置为 AF 模式。然后调用 FDCAN_DeInit/Init,它通过 MSP_INIT 回调也调用 GPIO Init,但针对的是原始 D0/D1 引脚。意思是B8/B9我设置了,D0/D1引脚同时启用。
这是一个显而易见的问题。 HAL 适合原型设计,但要小心,因为它会尝试“提供帮助”。充其量是未定义的行为,我通常不会发布如此愚蠢的错误。
但是...也许其他人会发现有趣的是,无论 FDCAN 状态机在这里做什么,都会在示波器图片中看到这种独特的输出。我最初没有仔细检查我的引脚设置,因为它看起来是正确的,我在示波器上得到输出,只是错误输出。我花了更多的时间检查外围设备设置和我提供给它的数据。
Solved.
After sending this message, the INIT bits were set in the
FDCAN->CCCR
register. There were values in the error counters. Indicates an internal error. I was using the HAL as a time saver, but it was over-writting my desired GPIO settings.I would set the pins B8/B9 to AF mode for FDCAN. Then call FDCAN_DeInit/Init, which via an MSP_INIT callback also calls GPIO Init, but for the original D0/D1 pins. Meaning the B8/B9 I set, and the D0/D1 pins were enabled at the same time.
This is an obvious problem. The HAL is fine for prototyping, but careful because it will try and "help". Undefined behavior at best and I normally wouldn't even post such a dumb mistake.
However... Maybe someone else finds it interesting that whatever the FDCAN state machine is doing here, makes this unique output seen in the scope picture. I initially didn't double check my pin setup, because it looked right, I was getting output on the scope, just the wrong output. I spent much more time going over peripheral settings and data I was feeding to it.