Skip to content

Conversation

@Ackleys
Copy link

@Ackleys Ackleys commented May 17, 2020

修复在STM32F103C8TX下,PWM 无法正常输出波形。

拉取/合并请求描述:(PR description)

[
在STM32F103C8T芯片上,使用PWM无法正常输出,在drv_pwm_.c 的stm32_hw_pwm_init函数内增加HAL_TIM_Base_Init即可正常输出PWM信号,在STM32F103C8T6核心板上验证成功。
]

以下的内容不应该在提交PR时的message修改,修改下述message,PR会被直接关闭。请在提交PR后,浏览器查看PR并对以下检查项逐项check,没问题后逐条在页面上打钩。
The following content must not be changed in submitted PR message. Otherwise, the PR will be closed immediately. After submitted PR, please use web browser to visit PR, and check items one by one, and ticked them if no problem.

当前拉取/合并请求的状态 Intent for your PR

必须选择一项 Choose one (Mandatory):

  • 本拉取/合并请求是一个草稿版本 This PR is for a code-review and is intended to get feedback
  • 本拉取/合并请求是一个成熟版本 This PR is mature, and ready to be integrated into the repo

代码质量 Code Quality:

我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:

  • 已经仔细查看过代码改动的对比 Already check the difference between PR and old code
  • 代码风格正确,包括缩进空格,命名及其他风格 Style guide is adhered to, including spacing, naming and other style
  • 没有垃圾代码,代码尽量精简,不包含#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up
  • 所有变更均有原因及合理的,并且不会影响到其他软件组件代码或BSP All modifications are justified and not affect other components or BSP
  • 对难懂代码均提供对应的注释 I've commented appropriately where code is tricky
  • 本拉取/合并请求代码是高质量的 Code in this PR is of high quality

修复在STM32F103C8TX下,PWM 无法正常输出波形。
@CLAassistant
Copy link

CLAassistant commented May 17, 2020

CLA assistant check
All committers have signed the CLA.

@BernardXiong BernardXiong requested a review from SummerGift May 17, 2020 16:01
tim->Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
#endif

#if defined(SOC_STM32F103C8TX)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感谢贡献代码,对于本次提交,我有如下两点建议:

首先,我们一般不会对某一个指定型号的芯片来修改驱动代码,一般是对应于某个系列,比如 F1 系列,由于 HAL 的兼容性,这样做是没有问题的。

第二点,你可以参考一下这个 ISSUE,然后检查一下本次修改是否也会造成同样的问题。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同样的,可以参考该 PR ,检查是否会造成同样的问题。

Copy link
Member

@SummerGift SummerGift left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

请根据建议完善相关提交代码 🔎

@geniusgogo
Copy link
Contributor

@summerlife 我看了之前我修改的PR,这里主要是因为CubeMX的兼容性导致的差异,我在L4上生成出来的有独立的PWM初始化接口HAL_TIM_PWM_MspInit,但是在F2上又没有生成。
这需要手动定义weak函数HAL_TIM_PWM_MspInit才行。

@BernardXiong
Copy link
Member

@summerlife 慎重考虑下这份PR,貌似确实存在这样的情况,如果这份PR确实时间久了推动不下去,请自行fix然后发出PR出来。

@BernardXiong BernardXiong added the BSP: STM32 BSP related with ST/STM32 label Jan 22, 2021
@icrazt icrazt mentioned this pull request Feb 7, 2021
8 tasks
@icrazt
Copy link
Contributor

icrazt commented Feb 7, 2021

@summerlife 我看了之前我修改的PR,这里主要是因为CubeMX的兼容性导致的差异,我在L4上生成出来的有独立的PWM初始化接口HAL_TIM_PWM_MspInit,但是在F2上又没有生成。
这需要手动定义weak函数HAL_TIM_PWM_MspInit才行。

我尝试了一下,只要在 CubeMX 中为 Timer 设置了 Clock Source,那么就不会生成独立的 HAL_TIM_PWM_MspInit 。目前大部分stm32的bsp已经预先设置了 Clock Source ,因此使用之前的 HAL_TIM_Base_Init会更好。
我在 PR fix stm32_hw_pwm_init 做了一下总结。你也可以在L4上试一下,如果配置了 Clock Source(非Disable)那么 PWM 的初始化应该会生成在 HAL_TIM_Base_MspInit 中,而非HAL_TIM_PWM_MspInit
如果按 #3337 修改,那么随着cube的配置不同,pwm初始化可能会生成在不同位置,进而导致无法正常输出。总体上还是预先在Cube中设置 Clock Source,保证PWM的MspInit位置固定比较好。

@mysterywolf mysterywolf added the discussion This PR/issue needs to be discussed later label Mar 12, 2021
@Guozhanxin
Copy link
Member

在一个pr里讨论吧: #5241

@Guozhanxin Guozhanxin closed this Jan 24, 2022
@mysterywolf
Copy link
Member

#7049

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSP: STM32 BSP related with ST/STM32 discussion This PR/issue needs to be discussed later

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants