问答

汇集网友智慧,解决技术难题

21ic问答首页 - 变量不用计算就可以自增吗?

RT se TI keil ARM HK32F030MF4P6 航顺

变量不用计算就可以自增吗?

winfpt2024-08-06
下边是航顺HK32F030MF4P6的官方基本定时器例程,看到里边定义了一个time变量,但是没看到有计算过程(在整个工程中其他文件中也没有找到time变量),请问变量不计算怎么可以自增?下附部分代码:
/**
******************************************************************************
* @file    main.c
* @author  Alexander
* @version V1.0
* @date    2022-xx-xx
* @brief   基本定时器
******************************************************************************
* @attention
*
* 实验平台:HK32F030M开发板
* 论坛    :https://bbs.21ic.com/iclist-1010-1.html
*
******************************************************************************
*/
#include "hk32f030m.h"
#include "bsp_led.h"
#include "bsp_TimBase.h"

volatile uint32_t time = 0; // ms 计时变量

/**
* @brief  主函数
* @param  
* @retval
*/

int main(void)
{
  /* LED 端口初始化 */
  LED_GPIO_Config();

  BASIC_TIM_Init();

  while (1)
  {
    if (time == 500) /* 1000 * 1ms = 1s 时间到 */
    {
      time = 0;
      /* LED1 取反 */
      HandLED_TOGGLE;
    }
  }
}

#ifdef USE_FULL_ASSERT
/**
* @brief  Reports the name of the source file and the source line number
*         where the assert_param error has occurred.
* @param  file: pointer to the source file name
* @param  line: assert_param error line source number
* @retval None
*/
void assert_failed(char *file, uint32_t line)
{
  /* User can add his own implementation to report the file name and line number,
     tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
  /* Infinite loop */

  while (1)
  {
  }
}
#endif /* USE_FULL_ASSERT */








我是新人,还没有家园币,暂时还没法设置悬赏,实在不好意思,麻烦大家了,多谢赐教!
回答 +关注 4
6607人浏览 10人回答问题 分享 举报
10 个回答

您需要登录后才可以回复 登录 | 注册