Skip to content

[bsp][renesas] fix clock_timer divider setup and sample startup sequence#11313

Open
illustriousness wants to merge 1 commit intoRT-Thread:masterfrom
illustriousness:test_5.3.0
Open

[bsp][renesas] fix clock_timer divider setup and sample startup sequence#11313
illustriousness wants to merge 1 commit intoRT-Thread:masterfrom
illustriousness:test_5.3.0

Conversation

@illustriousness
Copy link
Copy Markdown
Contributor

@illustriousness illustriousness commented Apr 4, 2026

Summary | 变更摘要

  • Fix GPT divider programming in CLOCK_TIMER_CTRL_FREQ_SET.

  • Correct GTCR.TPCS mapping for RA/FSP divider values.

  • Stop timer and unlock/restore GTWP before updating divider.

  • Return actual hardware timer frequency to clock_timer core.

  • In clock_timer_sample, prefer timer1, clear pending IRQ before
    start, and print callback deltas.

  • 修复 CLOCK_TIMER_CTRL_FREQ_SET 中 GPT 分频配置流程。

  • 按 RA/FSP 的分频映射正确写入 GTCR.TPCS

  • 更新分频前先停计数器并解锁/恢复 GTWP 写保护。

  • 将硬件实际频率回写给 clock_timer 核心。

  • clock_timer_sample 中默认使用 timer1,启动前清 pending 中断,
    并打印回调间隔。

Root Cause | 问题根因

The previous divider update path could cause mismatch between software
timeout conversion and hardware effective frequency, resulting in
unexpectedly short callback periods (for example around 10 ms).
旧的分频更新路径会导致软件超时换算与硬件实际频率不一致,从而出现回调周
期异常偏短(例如约 10 ms)。

Validation | 验证结果

  • Build passed with scons -j$(nproc) on ra6m3-hmi-board.

  • Runtime clock_timer_sample callback interval stabilizes around
    992/993 ms after first callback.

  • ra6m3-hmi-board 上执行 scons -j$(nproc) 编译通过。

  • 运行 clock_timer_sample 后,首个回调之后间隔稳定在 992/993 ms
    右。

Files | 涉及文件

  • bsp/renesas/libraries/HAL_Drivers/drivers/drv_timer.c

@github-actions github-actions bot added BSP BSP: Renesas BSP related with Renesas labels Apr 4, 2026
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

📌 Code Review Assignment

🏷️ Tag: bsp_renesas

Reviewers: kurisaW

Changed Files (Click to expand)
  • bsp/renesas/libraries/HAL_Drivers/drivers/drv_timer.c

📊 Current Review Status (Last Updated: 2026-04-08 21:44 CST)

  • kurisaW Pending Review

📝 Review Instructions

  1. 维护者可以通过单击此处来刷新审查状态: 🔄 刷新状态
    Maintainers can refresh the review status by clicking here: 🔄 Refresh Status

  2. 确认审核通过后评论 LGTM/lgtm
    Comment LGTM/lgtm after confirming approval

  3. PR合并前需至少一位维护者确认
    PR must be confirmed by at least one maintainer before merging

ℹ️ 刷新CI状态操作需要具备仓库写入权限。
ℹ️ Refresh CI status operation requires repository Write permission.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 4, 2026

👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread!

为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。
To ensure your code complies with RT-Thread's coding style, please run the code formatting workflow by following the steps below (If the formatting of CI fails to run).


🛠 操作步骤 | Steps

  1. 前往 Actions 页面 | Go to the Actions page
    点击进入工作流 → | Click to open workflow →

  2. 点击 Run workflow | Click Run workflow

  • 设置需排除的文件/目录(目录请以"/"结尾)
    Set files/directories to exclude (directories should end with "/")
  • 将目标分支设置为 \ Set the target branch to:test_5.3.0
  • 设置PR number为 \ Set the PR number to:11313
  1. 等待工作流完成 | Wait for the workflow to complete
    格式化后的代码将自动推送至你的分支。
    The formatted code will be automatically pushed to your branch.

完成后,提交将自动更新至 test_5.3.0 分支,关联的 Pull Request 也会同步更新。
Once completed, commits will be pushed to the test_5.3.0 branch automatically, and the related Pull Request will be updated.

如有问题欢迎联系我们,再次感谢您的贡献!💐
If you have any questions, feel free to reach out. Thanks again for your contribution!

#define GPT_GTWP_RESET_VALUE (0xA500U)

#ifdef SOC_SERIES_R9A07G0
#define TIMER_FSP_PRIV_CLOCK FSP_PRIV_CLOCK_PCLKGPTL
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

这块不需要加缩进

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

已修改

- fix GPT divider programming and TPCS mapping for clock_timer\n- stop counter and handle GTWP write protection before updating divider\n- return actual hardware frequency for consistent timeout conversion\n- improve clock_timer_sample startup sequence and callback interval logging\n- apply maintainer style suggestion: remove extra indentation in preprocessor defines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BSP: Renesas BSP related with Renesas BSP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants