在HAL_TIM_IRQHandler();这个函数的定义中都会有类似__HAL_TIM_GET_FLAG(htim, TIM_FLAG_CC1) != RESET获取这个标志位的操作,但是并没有清除此标志位,但是同一函数中有__HAL_TIM_GET_IT_SOURCE(htim, TIM_IT_CC1) !=RESET这样的获取中断标志的操作,函数中就有清除的操作,这是为什么?有大神来解释一下吗?
还有一个小问题就是有大神来解释一下__HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__) 和 __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)的具体区别是什么?
还有就是HAL_StatusTypeDef HAL_TIM_Base_Start(TIM_HandleTypeDef *htim);和HAL_StatusTypeDef HAL_TIM_Base_Start_IT(TIM_HandleTypeDef *htim);的区别。。。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
/**
* @brief Checks whether the specified TIM interrupt flag is set or not.
* @param __HANDLE__: specifies the TIM Handle.
* @param __FLAG__: specifies the TIM interrupt flag to check.
* This parameter can be one of the following values:
* @arg TIM_FLAG_UPDATE: Update interrupt flag
* @arg TIM_FLAG_CC1: Capture/Compare 1 interrupt flag
* @arg TIM_FLAG_CC2: Capture/Compare 2 interrupt flag
* @arg TIM_FLAG_CC3: Capture/Compare 3 interrupt flag
* @arg TIM_FLAG_CC4: Capture/Compare 4 interrupt flag
* @arg TIM_FLAG_COM: Commutation interrupt flag
* @arg TIM_FLAG_TRIGGER: Trigger interrupt flag
* @arg TIM_FLAG_BREAK: Break interrupt flag
* @arg TIM_FLAG_CC1OF: Capture/Compare 1 overcapture flag
* @arg TIM_FLAG_CC2OF: Capture/Compare 2 overcapture flag
* @arg TIM_FLAG_CC3OF: Capture/Compare 3 overcapture flag
* @arg TIM_FLAG_CC4OF: Capture/Compare 4 overcapture flag
* @retval The new state of __FLAG__ (TRUE or FALSE).
*/
#define __HAL_TIM_GET_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR &(__FLAG__)) == (__FLAG__))
/**
* @brief Checks whether the specified TIM interrupt has occurred or not.
* @param __HANDLE__: TIM handle
* @param __INTERRUPT__: specifies the TIM interrupt source to check.
* @retval The state of TIM_IT (SET or RESET).
*/
#define __HAL_TIM_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->DIER & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
[/mw_shl_code]
自己去stm32fxxx_hal_tim.h去找对应的代码, 就可以知道差异.
HAL_TIM_Base_Start_IT()会发中断, 没有带_IT()后绰的不发.
一周热门 更多>