[bsp][renesas] fix clock_timer divider setup and sample startup sequence#11313
[bsp][renesas] fix clock_timer divider setup and sample startup sequence#11313illustriousness wants to merge 1 commit intoRT-Thread:masterfrom
Conversation
📌 Code Review Assignment🏷️ Tag: bsp_renesasReviewers: kurisaW Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-04-08 21:44 CST)
📝 Review Instructions
|
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
| #define GPT_GTWP_RESET_VALUE (0xA500U) | ||
|
|
||
| #ifdef SOC_SERIES_R9A07G0 | ||
| #define TIMER_FSP_PRIV_CLOCK FSP_PRIV_CLOCK_PCLKGPTL |
- 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
f5ccc8f to
9c8041e
Compare
Summary | 变更摘要
Fix GPT divider programming in
CLOCK_TIMER_CTRL_FREQ_SET.Correct
GTCR.TPCSmapping for RA/FSP divider values.Stop timer and unlock/restore
GTWPbefore updating divider.Return actual hardware timer frequency to clock_timer core.
In
clock_timer_sample, prefertimer1, clear pending IRQ beforestart, 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)onra6m3-hmi-board.Runtime
clock_timer_samplecallback interval stabilizes around992/993 msafter first callback.在
ra6m3-hmi-board上执行scons -j$(nproc)编译通过。运行
clock_timer_sample后,首个回调之后间隔稳定在992/993 ms左右。
Files | 涉及文件
bsp/renesas/libraries/HAL_Drivers/drivers/drv_timer.c