主题中讨论的其他器件:AM62L、 SysConfig
工具/软件:
我尝试实现一个 NORTOS 计时器示例代码、该代码从0开始计数到设定的计时器周期值(例如 timerParams.periodInUsec = 0xfffff )使用 am62lx_11_00_05 SDK。 问题是、启动计时器后立即计时器计数器值(由检索 TimerP_getCount )不是从0开始、而是从非常高的开始-类似的 0xfffe67eb。 代码片段如下所示:
/* Timer setup and init here */ TimerP_Params timerParams; /* set timer clock source */ SOC_controlModuleUnlockMMR(SOC_DOMAIN_ID_MAIN, 2); *(volatile uint32_t*)AddrTranslateP_getLocalAddr(CONFIG_TIMER2_CLOCK_SRC_MUX_ADDR) = CONFIG_TIMER2_CLOCK_SRC_HFOSC0_CLKOUT; SOC_controlModuleLockMMR(SOC_DOMAIN_ID_MAIN, 2); gTimerBaseAddr[CONFIG_TIMER2] = (uint32_t)AddrTranslateP_getLocalAddr(CONFIG_TIMER2_BASE_ADDR); TimerP_Params_init(&timerParams); timerParams.inputPreScaler = 25*10; // Brings clock down to 100KHzTimer timerParams.inputClkHz = CONFIG_TIMER2_INPUT_CLK_HZ; timerParams.periodInUsec = 0xfffff; timerParams.periodInNsec = 0; timerParams.oneshotMode = 1; timerParams.enableOverflowInt = 0; TimerP_setup(gTimerBaseAddr[CONFIG_TIMER2], &timerParams); DebugP_log("Timer initialization done . . .\r\n"); TimerP_start(gTimerBaseAddr[CONFIG_TIMER2]); DebugP_log("Timer started . . .\r\n"); ClockP_usleep(2000); // Wait for 2ms prev_count = TimerP_getCount(gTimerBaseAddr[CONFIG_TIMER2]); DebugP_log("initial prev_counter:%x\r\n", prev_count); for(i = 0; i < prev_count; i++){ ClockP_usleep(2000); // Wait for 2ms count = TimerP_getCount(gTimerBaseAddr[CONFIG_TIMER2]); DebugP_log("counter:%x\r\n", count); prev_count = count; }
输出如下所示:
Timer initialization done . . . Timer started . . . initial prev_counter:fffe67eb counter:fffe69f8 counter:fffe6b8e counter:fffe6d24 counter:fffe6ebb counter:fffe7051 counter:fffe71e7 counter:fffe737d counter:fffe7514 counter:fffe76aa counter:fffe7840 counter:fffe79d7 counter:fffe7b6d counter:fffe7d03 counter:fffe7e99 counter:fffe8030 counter:fffe81c6 counter:fffe835c counter:fffe84f3 counter:fffe8689 counter:fffe881f counter:fffe89b5 counter:fffe8b4c counter:fffe8ce2 counter:fffe8e78 counter:fffe900e counter:fffe91a5 counter:fffe933b counter:fffe94d1 counter:fffe9668 counter:fffe97fe counter:fffe9994 counter:fffe9b2a counter:fffe9cc1 counter:fffe9e57 counter:fffe9fed counter:fffea184 counter:fffea31a counter:fffea4b0 counter:fffea646 counter:fffea7dd counter:fffea973 counter:fffeab09 counter:fffeaca0 counter:fffeae36 counter:fffeafcc counter:fffeb162 counter:fffeb2f9 counter:fffeb48f counter:fffeb625 counter:fffeb7bc counter:fffeb952 counter:fffebae8 counter:fffebc7e counter:fffebe15 counter:fffebfab counter:fffec141 counter:fffec2d8 counter:fffec46e counter:fffec604 counter:fffec79a counter:fffec931 counter:fffecac7 counter:fffecc5d counter:fffecdf4 counter:fffecf8a counter:fffed120 counter:fffed2b6 counter:fffed44d counter:fffed5e3 counter:fffed779 counter:fffed90f counter:fffedaa6 counter:fffedc3c counter:fffeddd2 counter:fffedf69 counter:fffee0ff counter:fffee295 counter:fffee42b counter:fffee5c2 counter:fffee758 counter:fffee8ee counter:fffeea85 counter:fffeec1b counter:fffeedb1 counter:fffeef47 counter:fffef0de counter:fffef274 counter:fffef40a counter:fffef5a1 counter:fffef737 counter:fffef8cd counter:fffefa63 counter:fffefbfa counter:fffefd90 counter:fffeff26 counter:ffff00bd counter:ffff0253 counter:ffff03e9 counter:ffff057f counter:ffff0716 counter:ffff08ac counter:ffff0a42 counter:ffff0bd8 counter:ffff0d6f counter:ffff0f05 counter:ffff109b counter:ffff1232 counter:ffff13c8 counter:ffff155e counter:ffff16f5 counter:ffff188b counter:ffff1a21 counter:ffff1bb7 counter:ffff1d4e counter:ffff1ee4 counter:ffff207a counter:ffff2211 counter:ffff23a7 counter:ffff253d counter:ffff26d4 counter:ffff286a counter:ffff2a00 counter:ffff2b96 counter:ffff2d2d counter:ffff2ec3 counter:ffff3059 counter:ffff31f0 counter:ffff3386 counter:ffff351c counter:ffff36b3 counter:ffff3849 counter:ffff39df counter:ffff3b75 counter:ffff3d0c counter:ffff3ea2 counter:ffff4038 counter:ffff41cf counter:ffff4365 counter:ffff44fb counter:ffff4691 counter:ffff4828 counter:ffff49be counter:ffff4b54 counter:ffff4ceb counter:ffff4e81 counter:ffff5017 counter:ffff51ae counter:ffff5344 counter:ffff54da counter:ffff5670 counter:ffff5807 counter:ffff599d counter:ffff5b33 counter:ffff5cca counter:ffff5e60 counter:ffff5ff6 counter:ffff618c counter:ffff6323 counter:ffff64b9 counter:ffff664f counter:ffff67e6 counter:ffff697c counter:ffff6b12 counter:ffff6ca8 counter:ffff6e3f counter:ffff6fd5 counter:ffff716b counter:ffff7302 counter:ffff7498 counter:ffff762e counter:ffff77c4 counter:ffff795b counter:ffff7af1 counter:ffff7c87 counter:ffff7e1d counter:ffff7fb4 counter:ffff814a counter:ffff82e0 counter:ffff8477 counter:ffff860d counter:ffff87a3 counter:ffff8939 counter:ffff8ad0 counter:ffff8c66 counter:ffff8dfc counter:ffff8f93 counter:ffff9129 counter:ffff92bf counter:ffff9455 counter:ffff95ec counter:ffff9782 counter:ffff9918 counter:ffff9aaf counter:ffff9c45 counter:ffff9ddb counter:ffff9f71 counter:ffffa108 counter:ffffa29e counter:ffffa434 counter:ffffa5ca counter:ffffa761 counter:ffffa8f7 counter:ffffaa8d counter:ffffac24 counter:ffffadba counter:ffffaf50 counter:ffffb0e6 counter:ffffb27d counter:ffffb413 counter:ffffb5a9 counter:ffffb740 counter:ffffb8d6 counter:ffffba6c counter:ffffbc02 counter:ffffbd99 counter:ffffbf2f counter:ffffc0c5 counter:ffffc25c counter:ffffc3f2 counter:ffffc588 counter:ffffc71e counter:ffffc8b5 counter:ffffca4b counter:ffffcbe1 counter:ffffcd78 counter:ffffcf0e counter:ffffd0a4 counter:ffffd23a counter:ffffd3d1 counter:ffffd567 counter:ffffd6fd counter:ffffd894 counter:ffffda2a counter:ffffdbc0 counter:ffffdd56 counter:ffffdeed counter:ffffe083 counter:ffffe219 counter:ffffe3af counter:ffffe546 counter:ffffe6dc counter:ffffe872 counter:ffffea09 counter:ffffeb9f counter:ffffed35 counter:ffffeecc counter:fffff062 counter:fffff1f8 counter:fffff38e counter:fffff525 counter:fffff6bb counter:fffff851 counter:fffff9e7 counter:fffffb7e counter:fffffd14 counter:fffffeaa counter:0
调试时、我注意到在将 countVal 加载到中的 TCRR 计数器寄存器之前、它可能与计算 countVal 的方式有关 TimerP_SETUP 传递函数
请建议如何获取计时器计数器值以从零开始计数到设定的周期。
谢谢您、
Simeon