查看: 3129|回复: 0

[原创] 【野火i.MX RT1052】5.滴答滴答SysTick

[复制链接]
  • TA的每日心情
    开心
    2020-9-28 22:37
  • 签到天数: 456 天

    连续签到: 1 天

    [LV.9]以坛为家II

    发表于 2018-6-12 23:07:31 | 显示全部楼层 |阅读模式
    分享到:
    本帖最后由 ALTIUM2 于 2018-6-13 23:45 编辑

    5.滴答滴答SysTick
      cortex M0,M4,M7虽然型号一直在变,但是滴答滴答的SysTick还是没有变。它在实时应用处理时十分的有用,高效,如果跑RTOS也十分的方便,不像以前的MCU还得自己选个定时器作为OS时钟。  具体可以参照CORTEX-M7中指南手册中关于SycTick的描述:
    jietu2.jpg

    1.简介
    SysTick 是属于Cortex 内核的外设,计数器每计数一次的时间为 1/SYSCLK,例如RT1052的主频为528MHZ(工业528MHZ,商业600MHZ)。所以可以以1/528M为时间分辨率。而SysTick—系统定时器有 4 个寄存器。

    jietu51.jpg

    2.寄存器描述
    寄存器名称  寄存器描述
    CTRL  SysTick 控制及状态寄存器
    LOAD  SysTick 重装载数值寄存器
    VAL  SysTick 当前数值寄存器
    CALIB  SysTick 校准数值寄存器

    3.使用方法
    a、配置SysTick 中断
      由于SysTick是一个24位的寄存器,用它必须要按照流程,同时需要打开相应的中断设置。
    (SysTick 的外设中断比较低,容易被欺负,哈哈)

    b、配置System Tick代码
    1.   \brief   System Tick Configuration
    2.   \details Initializes the System Timer and its interrupt, and starts the System Tick Timer.
    3.            Counter is in free running mode to generate periodic interrupts.
    4.   \param [in]  ticks  Number of ticks between two interrupts.
    5.   \return          0  Function succeeded.
    6.   \return          1  Function failed.
    7.   \note    When the variable <b>__Vendor_SysTickConfig</b> is set to 1, then the
    8.            function <b>SysTick_Config</b> is not included. In this case, the file <b><i>device</i>.h</b>
    9.            must contain a vendor-specific implementation of this function.
    10. */
    11. __STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
    12. {
    13.   if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
    14.   {
    15.     return (1UL);                                                   /* Reload value impossible */
    16.   }

    17.   SysTick->LOAD  = (uint32_t)(ticks - 1UL);                         /* set reload register */
    18.   NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
    19.   SysTick->VAL   = 0UL;                                             /* Load the SysTick Counter Value */
    20.   SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
    21.                    SysTick_CTRL_TICKINT_Msk   |
    22.                    SysTick_CTRL_ENABLE_Msk;                         /* Enable SysTick IRQ and SysTick Timer */
    23.   return (0UL);                                                     /* Function successful */
    24. }
    复制代码


    4.疗效^
    就不展示了,也就灯



    回复

    使用道具 举报

    您需要登录后才可以回帖 注册/登录

    本版积分规则

    关闭

    站长推荐上一条 /2 下一条



    手机版|小黑屋|与非网

    GMT+8, 2024-4-26 17:06 , Processed in 0.115338 second(s), 16 queries , MemCache On.

    ICP经营许可证 苏B2-20140176  苏ICP备14012660号-2   苏州灵动帧格网络科技有限公司 版权所有.

    苏公网安备 32059002001037号

    Powered by Discuz! X3.4

    Copyright © 2001-2024, Tencent Cloud.