STM32L4xx_HAL_Driver  1.14.0
TIM Peripheral Control functions

Peripheral Control functions. More...

Functions

HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel (TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel)
 Initializes the TIM Output Compare Channels according to the specified parameters in the TIM_OC_InitTypeDef. More...
 
HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel (TIM_HandleTypeDef *htim, TIM_OC_InitTypeDef *sConfig, uint32_t Channel)
 Initializes the TIM PWM channels according to the specified parameters in the TIM_OC_InitTypeDef. More...
 
HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel (TIM_HandleTypeDef *htim, TIM_IC_InitTypeDef *sConfig, uint32_t Channel)
 Initializes the TIM Input Capture Channels according to the specified parameters in the TIM_IC_InitTypeDef. More...
 
HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel (TIM_HandleTypeDef *htim, TIM_OnePulse_InitTypeDef *sConfig, uint32_t OutputChannel, uint32_t InputChannel)
 Initializes the TIM One Pulse Channels according to the specified parameters in the TIM_OnePulse_InitTypeDef. More...
 
HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear (TIM_HandleTypeDef *htim, TIM_ClearInputConfigTypeDef *sClearInputConfig, uint32_t Channel)
 Configures the OCRef clear feature. More...
 
HAL_StatusTypeDef HAL_TIM_ConfigClockSource (TIM_HandleTypeDef *htim, TIM_ClockConfigTypeDef *sClockSourceConfig)
 Configures the clock source to be used. More...
 
HAL_StatusTypeDef HAL_TIM_ConfigTI1Input (TIM_HandleTypeDef *htim, uint32_t TI1_Selection)
 Selects the signal connected to the TI1 input: direct from CH1_input or a XOR combination between CH1_input, CH2_input & CH3_input. More...
 
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro (TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
 Configures the TIM in Slave mode. More...
 
HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT (TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
 Configures the TIM in Slave mode in interrupt mode. More...
 
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart (TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength)
 Configure the DMA Burst to transfer Data from the memory to the TIM peripheral. More...
 
HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop (TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
 Stops the TIM DMA Burst mode. More...
 
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart (TIM_HandleTypeDef *htim, uint32_t BurstBaseAddress, uint32_t BurstRequestSrc, uint32_t *BurstBuffer, uint32_t BurstLength)
 Configure the DMA Burst to transfer Data from the TIM peripheral to the memory. More...
 
HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop (TIM_HandleTypeDef *htim, uint32_t BurstRequestSrc)
 Stop the DMA burst reading. More...
 
HAL_StatusTypeDef HAL_TIM_GenerateEvent (TIM_HandleTypeDef *htim, uint32_t EventSource)
 Generate a software event. More...
 
uint32_t HAL_TIM_ReadCapturedValue (TIM_HandleTypeDef *htim, uint32_t Channel)
 Read the captured value from Capture Compare unit. More...
 

Detailed Description

Peripheral Control functions.

TIM Peripheral Control functions.

  ==============================================================================
                   ##### Peripheral Control functions #####
  ==============================================================================
 [..]
   This section provides functions allowing to:
      (+) Configure The Input Output channels for OC, PWM, IC or One Pulse mode.
      (+) Configure External Clock source.
      (+) Configure Complementary channels, break features and dead time.
      (+) Configure Master and the Slave synchronization.
      (+) Configure the DMA Burst Mode.

Function Documentation

◆ HAL_TIM_ConfigClockSource()

HAL_StatusTypeDef HAL_TIM_ConfigClockSource ( TIM_HandleTypeDef htim,
TIM_ClockConfigTypeDef sClockSourceConfig 
)

Configures the clock source to be used.

Parameters
htimTIM handle
sClockSourceConfigpointer to a TIM_ClockConfigTypeDef structure that contains the clock source information for the TIM peripheral.
Return values
HALstatus

Definition at line 4611 of file stm32l4xx_hal_tim.c.

4612 {
4613  uint32_t tmpsmcr;
4614 
4615  /* Process Locked */
4616  __HAL_LOCK(htim);
4617 
4618  htim->State = HAL_TIM_STATE_BUSY;
4619 
4620  /* Check the parameters */
4621  assert_param(IS_TIM_CLOCKSOURCE(sClockSourceConfig->ClockSource));
4622 
4623  /* Reset the SMS, TS, ECE, ETPS and ETRF bits */
4624  tmpsmcr = htim->Instance->SMCR;
4625  tmpsmcr &= ~(TIM_SMCR_SMS | TIM_SMCR_TS);
4626  tmpsmcr &= ~(TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP);
4627  htim->Instance->SMCR = tmpsmcr;
4628 
4629  switch (sClockSourceConfig->ClockSource)
4630  {
4631  case TIM_CLOCKSOURCE_INTERNAL:
4632  {
4633  assert_param(IS_TIM_INSTANCE(htim->Instance));
4634  break;
4635  }
4636 
4637  case TIM_CLOCKSOURCE_ETRMODE1:
4638  {
4639  /* Check whether or not the timer instance supports external trigger input mode 1 (ETRF)*/
4640  assert_param(IS_TIM_CLOCKSOURCE_ETRMODE1_INSTANCE(htim->Instance));
4641 
4642  /* Check ETR input conditioning related parameters */
4643  assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler));
4644  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4645  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4646 
4647  /* Configure the ETR Clock source */
4648  TIM_ETR_SetConfig(htim->Instance,
4649  sClockSourceConfig->ClockPrescaler,
4650  sClockSourceConfig->ClockPolarity,
4651  sClockSourceConfig->ClockFilter);
4652 
4653  /* Select the External clock mode1 and the ETRF trigger */
4654  tmpsmcr = htim->Instance->SMCR;
4655  tmpsmcr |= (TIM_SLAVEMODE_EXTERNAL1 | TIM_CLOCKSOURCE_ETRMODE1);
4656  /* Write to TIMx SMCR */
4657  htim->Instance->SMCR = tmpsmcr;
4658  break;
4659  }
4660 
4661  case TIM_CLOCKSOURCE_ETRMODE2:
4662  {
4663  /* Check whether or not the timer instance supports external trigger input mode 2 (ETRF)*/
4664  assert_param(IS_TIM_CLOCKSOURCE_ETRMODE2_INSTANCE(htim->Instance));
4665 
4666  /* Check ETR input conditioning related parameters */
4667  assert_param(IS_TIM_CLOCKPRESCALER(sClockSourceConfig->ClockPrescaler));
4668  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4669  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4670 
4671  /* Configure the ETR Clock source */
4672  TIM_ETR_SetConfig(htim->Instance,
4673  sClockSourceConfig->ClockPrescaler,
4674  sClockSourceConfig->ClockPolarity,
4675  sClockSourceConfig->ClockFilter);
4676  /* Enable the External clock mode2 */
4677  htim->Instance->SMCR |= TIM_SMCR_ECE;
4678  break;
4679  }
4680 
4681  case TIM_CLOCKSOURCE_TI1:
4682  {
4683  /* Check whether or not the timer instance supports external clock mode 1 */
4684  assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance));
4685 
4686  /* Check TI1 input conditioning related parameters */
4687  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4688  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4689 
4690  TIM_TI1_ConfigInputStage(htim->Instance,
4691  sClockSourceConfig->ClockPolarity,
4692  sClockSourceConfig->ClockFilter);
4693  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1);
4694  break;
4695  }
4696 
4697  case TIM_CLOCKSOURCE_TI2:
4698  {
4699  /* Check whether or not the timer instance supports external clock mode 1 (ETRF)*/
4700  assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance));
4701 
4702  /* Check TI2 input conditioning related parameters */
4703  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4704  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4705 
4706  TIM_TI2_ConfigInputStage(htim->Instance,
4707  sClockSourceConfig->ClockPolarity,
4708  sClockSourceConfig->ClockFilter);
4709  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI2);
4710  break;
4711  }
4712 
4713  case TIM_CLOCKSOURCE_TI1ED:
4714  {
4715  /* Check whether or not the timer instance supports external clock mode 1 */
4716  assert_param(IS_TIM_CLOCKSOURCE_TIX_INSTANCE(htim->Instance));
4717 
4718  /* Check TI1 input conditioning related parameters */
4719  assert_param(IS_TIM_CLOCKPOLARITY(sClockSourceConfig->ClockPolarity));
4720  assert_param(IS_TIM_CLOCKFILTER(sClockSourceConfig->ClockFilter));
4721 
4722  TIM_TI1_ConfigInputStage(htim->Instance,
4723  sClockSourceConfig->ClockPolarity,
4724  sClockSourceConfig->ClockFilter);
4725  TIM_ITRx_SetConfig(htim->Instance, TIM_CLOCKSOURCE_TI1ED);
4726  break;
4727  }
4728 
4729  case TIM_CLOCKSOURCE_ITR0:
4730  case TIM_CLOCKSOURCE_ITR1:
4731  case TIM_CLOCKSOURCE_ITR2:
4732  case TIM_CLOCKSOURCE_ITR3:
4733  {
4734  /* Check whether or not the timer instance supports internal trigger input */
4735  assert_param(IS_TIM_CLOCKSOURCE_ITRX_INSTANCE(htim->Instance));
4736 
4737  TIM_ITRx_SetConfig(htim->Instance, sClockSourceConfig->ClockSource);
4738  break;
4739  }
4740 
4741  default:
4742  break;
4743  }
4744  htim->State = HAL_TIM_STATE_READY;
4745 
4746  __HAL_UNLOCK(htim);
4747 
4748  return HAL_OK;
4749 }
static void TIM_TI1_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
Configure the Polarity and Filter for TI1.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
static void TIM_TI2_ConfigInputStage(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICFilter)
Configure the Polarity and Filter for TI2.
return HAL_OK
static void TIM_ITRx_SetConfig(TIM_TypeDef *TIMx, uint32_t InputTriggerSource)
Selects the Input Trigger source.
void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler, uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
Configures the TIMx External Trigger (ETR).
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_ConfigOCrefClear()

HAL_StatusTypeDef HAL_TIM_ConfigOCrefClear ( TIM_HandleTypeDef htim,
TIM_ClearInputConfigTypeDef sClearInputConfig,
uint32_t  Channel 
)

Configures the OCRef clear feature.

Parameters
htimTIM handle
sClearInputConfigpointer to a TIM_ClearInputConfigTypeDef structure that contains the OCREF clear feature and parameters for the TIM peripheral.
Channelspecifies the TIM Channel This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1
  • TIM_CHANNEL_2: TIM Channel 2
  • TIM_CHANNEL_3: TIM Channel 3
  • TIM_CHANNEL_4: TIM Channel 4
  • TIM_CHANNEL_5: TIM Channel 5
  • TIM_CHANNEL_6: TIM Channel 6
Return values
HALstatus

Definition at line 4450 of file stm32l4xx_hal_tim.c.

4453 {
4454  /* Check the parameters */
4455  assert_param(IS_TIM_OCXREF_CLEAR_INSTANCE(htim->Instance));
4456  assert_param(IS_TIM_CLEARINPUT_SOURCE(sClearInputConfig->ClearInputSource));
4457 
4458  /* Process Locked */
4459  __HAL_LOCK(htim);
4460 
4461  htim->State = HAL_TIM_STATE_BUSY;
4462 
4463  switch (sClearInputConfig->ClearInputSource)
4464  {
4465  case TIM_CLEARINPUTSOURCE_NONE:
4466  {
4467  /* Clear the OCREF clear selection bit and the the ETR Bits */
4468  CLEAR_BIT(htim->Instance->SMCR, (TIM_SMCR_OCCS | TIM_SMCR_ETF | TIM_SMCR_ETPS | TIM_SMCR_ECE | TIM_SMCR_ETP));
4469  break;
4470  }
4471  case TIM_CLEARINPUTSOURCE_OCREFCLR:
4472  {
4473  /* Clear the OCREF clear selection bit */
4474  CLEAR_BIT(htim->Instance->SMCR, TIM_SMCR_OCCS);
4475  }
4476  break;
4477 
4478  case TIM_CLEARINPUTSOURCE_ETR:
4479  {
4480  /* Check the parameters */
4481  assert_param(IS_TIM_CLEARINPUT_POLARITY(sClearInputConfig->ClearInputPolarity));
4482  assert_param(IS_TIM_CLEARINPUT_PRESCALER(sClearInputConfig->ClearInputPrescaler));
4483  assert_param(IS_TIM_CLEARINPUT_FILTER(sClearInputConfig->ClearInputFilter));
4484 
4485  /* When OCRef clear feature is used with ETR source, ETR prescaler must be off */
4486  if (sClearInputConfig->ClearInputPrescaler != TIM_CLEARINPUTPRESCALER_DIV1)
4487  {
4488  htim->State = HAL_TIM_STATE_READY;
4489  __HAL_UNLOCK(htim);
4490  return HAL_ERROR;
4491  }
4492 
4493  TIM_ETR_SetConfig(htim->Instance,
4494  sClearInputConfig->ClearInputPrescaler,
4495  sClearInputConfig->ClearInputPolarity,
4496  sClearInputConfig->ClearInputFilter);
4497 
4498  /* Set the OCREF clear selection bit */
4499  SET_BIT(htim->Instance->SMCR, TIM_SMCR_OCCS);
4500  break;
4501  }
4502 
4503  default:
4504  break;
4505  }
4506 
4507  switch (Channel)
4508  {
4509  case TIM_CHANNEL_1:
4510  {
4511  if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
4512  {
4513  /* Enable the OCREF clear feature for Channel 1 */
4514  SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
4515  }
4516  else
4517  {
4518  /* Disable the OCREF clear feature for Channel 1 */
4519  CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC1CE);
4520  }
4521  break;
4522  }
4523  case TIM_CHANNEL_2:
4524  {
4525  if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
4526  {
4527  /* Enable the OCREF clear feature for Channel 2 */
4528  SET_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
4529  }
4530  else
4531  {
4532  /* Disable the OCREF clear feature for Channel 2 */
4533  CLEAR_BIT(htim->Instance->CCMR1, TIM_CCMR1_OC2CE);
4534  }
4535  break;
4536  }
4537  case TIM_CHANNEL_3:
4538  {
4539  if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
4540  {
4541  /* Enable the OCREF clear feature for Channel 3 */
4542  SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
4543  }
4544  else
4545  {
4546  /* Disable the OCREF clear feature for Channel 3 */
4547  CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC3CE);
4548  }
4549  break;
4550  }
4551  case TIM_CHANNEL_4:
4552  {
4553  if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
4554  {
4555  /* Enable the OCREF clear feature for Channel 4 */
4556  SET_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
4557  }
4558  else
4559  {
4560  /* Disable the OCREF clear feature for Channel 4 */
4561  CLEAR_BIT(htim->Instance->CCMR2, TIM_CCMR2_OC4CE);
4562  }
4563  break;
4564  }
4565  case TIM_CHANNEL_5:
4566  {
4567  if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
4568  {
4569  /* Enable the OCREF clear feature for Channel 5 */
4570  SET_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC5CE);
4571  }
4572  else
4573  {
4574  /* Disable the OCREF clear feature for Channel 5 */
4575  CLEAR_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC5CE);
4576  }
4577  break;
4578  }
4579  case TIM_CHANNEL_6:
4580  {
4581  if (sClearInputConfig->ClearInputState != (uint32_t)DISABLE)
4582  {
4583  /* Enable the OCREF clear feature for Channel 6 */
4584  SET_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC6CE);
4585  }
4586  else
4587  {
4588  /* Disable the OCREF clear feature for Channel 6 */
4589  CLEAR_BIT(htim->Instance->CCMR3, TIM_CCMR3_OC6CE);
4590  }
4591  break;
4592  }
4593  default:
4594  break;
4595  }
4596 
4597  htim->State = HAL_TIM_STATE_READY;
4598 
4599  __HAL_UNLOCK(htim);
4600 
4601  return HAL_OK;
4602 }
__HAL_UNLOCK(hrtc)
CLEAR_BIT(hrtc->Instance->CR, RTC_CR_WUTE)
__HAL_LOCK(hrtc)
return HAL_OK
void TIM_ETR_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ExtTRGPrescaler, uint32_t TIM_ExtTRGPolarity, uint32_t ExtTRGFilter)
Configures the TIMx External Trigger (ETR).
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_ConfigTI1Input()

HAL_StatusTypeDef HAL_TIM_ConfigTI1Input ( TIM_HandleTypeDef htim,
uint32_t  TI1_Selection 
)

Selects the signal connected to the TI1 input: direct from CH1_input or a XOR combination between CH1_input, CH2_input & CH3_input.

Parameters
htimTIM handle.
TI1_SelectionIndicate whether or not channel 1 is connected to the output of a XOR gate. This parameter can be one of the following values:
  • TIM_TI1SELECTION_CH1: The TIMx_CH1 pin is connected to TI1 input
  • TIM_TI1SELECTION_XORCOMBINATION: The TIMx_CH1, CH2 and CH3 pins are connected to the TI1 input (XOR combination)
Return values
HALstatus

Definition at line 4763 of file stm32l4xx_hal_tim.c.

4764 {
4765  uint32_t tmpcr2;
4766 
4767  /* Check the parameters */
4768  assert_param(IS_TIM_XOR_INSTANCE(htim->Instance));
4769  assert_param(IS_TIM_TI1SELECTION(TI1_Selection));
4770 
4771  /* Get the TIMx CR2 register value */
4772  tmpcr2 = htim->Instance->CR2;
4773 
4774  /* Reset the TI1 selection */
4775  tmpcr2 &= ~TIM_CR2_TI1S;
4776 
4777  /* Set the TI1 selection */
4778  tmpcr2 |= TI1_Selection;
4779 
4780  /* Write to TIMxCR2 */
4781  htim->Instance->CR2 = tmpcr2;
4782 
4783  return HAL_OK;
4784 }
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_DMABurst_ReadStart()

HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStart ( TIM_HandleTypeDef htim,
uint32_t  BurstBaseAddress,
uint32_t  BurstRequestSrc,
uint32_t *  BurstBuffer,
uint32_t  BurstLength 
)

Configure the DMA Burst to transfer Data from the TIM peripheral to the memory.

Parameters
htimTIM handle
BurstBaseAddressTIM Base address from where the DMA will start the Data read This parameter can be one of the following values:
  • TIM_DMABASE_CR1
  • TIM_DMABASE_CR2
  • TIM_DMABASE_SMCR
  • TIM_DMABASE_DIER
  • TIM_DMABASE_SR
  • TIM_DMABASE_EGR
  • TIM_DMABASE_CCMR1
  • TIM_DMABASE_CCMR2
  • TIM_DMABASE_CCER
  • TIM_DMABASE_CNT
  • TIM_DMABASE_PSC
  • TIM_DMABASE_ARR
  • TIM_DMABASE_RCR
  • TIM_DMABASE_CCR1
  • TIM_DMABASE_CCR2
  • TIM_DMABASE_CCR3
  • TIM_DMABASE_CCR4
  • TIM_DMABASE_BDTR
  • TIM_DMABASE_OR1
  • TIM_DMABASE_CCMR3
  • TIM_DMABASE_CCR5
  • TIM_DMABASE_CCR6
  • TIM_DMABASE_OR2
  • TIM_DMABASE_OR3
BurstRequestSrcTIM DMA Request sources This parameter can be one of the following values:
  • TIM_DMA_UPDATE: TIM update Interrupt source
  • TIM_DMA_CC1: TIM Capture Compare 1 DMA source
  • TIM_DMA_CC2: TIM Capture Compare 2 DMA source
  • TIM_DMA_CC3: TIM Capture Compare 3 DMA source
  • TIM_DMA_CC4: TIM Capture Compare 4 DMA source
  • TIM_DMA_COM: TIM Commutation DMA source
  • TIM_DMA_TRIGGER: TIM Trigger DMA source
BurstBufferThe Buffer address.
BurstLengthDMA Burst length. This parameter can be one value between: TIM_DMABURSTLENGTH_1TRANSFER and TIM_DMABURSTLENGTH_18TRANSFERS.
Note
This function should be used only when BurstLength is equal to DMA data transfer length.
Return values
HALstatus

Definition at line 4168 of file stm32l4xx_hal_tim.c.

4170 {
4171  /* Check the parameters */
4172  assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
4173  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
4174  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4175  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
4176 
4177  if ((htim->State == HAL_TIM_STATE_BUSY))
4178  {
4179  return HAL_BUSY;
4180  }
4181  else if ((htim->State == HAL_TIM_STATE_READY))
4182  {
4183  if ((BurstBuffer == NULL) && (BurstLength > 0U))
4184  {
4185  return HAL_ERROR;
4186  }
4187  else
4188  {
4189  htim->State = HAL_TIM_STATE_BUSY;
4190  }
4191  }
4192  else
4193  {
4194  /* nothing to do */
4195  }
4196  switch (BurstRequestSrc)
4197  {
4198  case TIM_DMA_UPDATE:
4199  {
4200  /* Set the DMA Period elapsed callbacks */
4201  htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
4202  htim->hdma[TIM_DMA_ID_UPDATE]->XferHalfCpltCallback = TIM_DMAPeriodElapsedHalfCplt;
4203 
4204  /* Set the DMA error callback */
4205  htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
4206 
4207  /* Enable the DMA channel */
4208  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4209  {
4210  return HAL_ERROR;
4211  }
4212  break;
4213  }
4214  case TIM_DMA_CC1:
4215  {
4216  /* Set the DMA capture callbacks */
4217  htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMACaptureCplt;
4218  htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
4219 
4220  /* Set the DMA error callback */
4221  htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
4222 
4223  /* Enable the DMA channel */
4224  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4225  {
4226  return HAL_ERROR;
4227  }
4228  break;
4229  }
4230  case TIM_DMA_CC2:
4231  {
4232  /* Set the DMA capture/compare callbacks */
4233  htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMACaptureCplt;
4234  htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
4235 
4236  /* Set the DMA error callback */
4237  htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
4238 
4239  /* Enable the DMA channel */
4240  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4241  {
4242  return HAL_ERROR;
4243  }
4244  break;
4245  }
4246  case TIM_DMA_CC3:
4247  {
4248  /* Set the DMA capture callbacks */
4249  htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMACaptureCplt;
4250  htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
4251 
4252  /* Set the DMA error callback */
4253  htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
4254 
4255  /* Enable the DMA channel */
4256  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4257  {
4258  return HAL_ERROR;
4259  }
4260  break;
4261  }
4262  case TIM_DMA_CC4:
4263  {
4264  /* Set the DMA capture callbacks */
4265  htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMACaptureCplt;
4266  htim->hdma[TIM_DMA_ID_CC4]->XferHalfCpltCallback = TIM_DMACaptureHalfCplt;
4267 
4268  /* Set the DMA error callback */
4269  htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
4270 
4271  /* Enable the DMA channel */
4272  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4273  {
4274  return HAL_ERROR;
4275  }
4276  break;
4277  }
4278  case TIM_DMA_COM:
4279  {
4280  /* Set the DMA commutation callbacks */
4281  htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
4282  htim->hdma[TIM_DMA_ID_COMMUTATION]->XferHalfCpltCallback = TIMEx_DMACommutationHalfCplt;
4283 
4284  /* Set the DMA error callback */
4285  htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError ;
4286 
4287  /* Enable the DMA channel */
4288  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4289  {
4290  return HAL_ERROR;
4291  }
4292  break;
4293  }
4294  case TIM_DMA_TRIGGER:
4295  {
4296  /* Set the DMA trigger callbacks */
4297  htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
4298  htim->hdma[TIM_DMA_ID_TRIGGER]->XferHalfCpltCallback = TIM_DMATriggerHalfCplt;
4299 
4300  /* Set the DMA error callback */
4301  htim->hdma[TIM_DMA_ID_TRIGGER]->XferErrorCallback = TIM_DMAError ;
4302 
4303  /* Enable the DMA channel */
4304  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)&htim->Instance->DMAR, (uint32_t)BurstBuffer, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4305  {
4306  return HAL_ERROR;
4307  }
4308  break;
4309  }
4310  default:
4311  break;
4312  }
4313 
4314  /* configure the DMA Burst Mode */
4315  htim->Instance->DCR = (BurstBaseAddress | BurstLength);
4316 
4317  /* Enable the TIM DMA Request */
4318  __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
4319 
4320  htim->State = HAL_TIM_STATE_READY;
4321 
4322  /* Return function status */
4323  return HAL_OK;
4324 }
void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Commutation half complete callback.
static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Period Elapse half complete callback.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
void TIM_DMAError(DMA_HandleTypeDef *hdma)
TIM DMA error callback.
return HAL_OK
static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Trigger half complete callback.
void TIM_DMACaptureHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Capture half complete callback.
void TIM_DMACaptureCplt(DMA_HandleTypeDef *hdma)
TIM DMA Capture complete callback.
static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma)
TIM DMA Trigger callback.
static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma)
TIM DMA Period Elapse complete callback.
void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma)
TIM DMA Commutation callback.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_DMABurst_ReadStop()

HAL_StatusTypeDef HAL_TIM_DMABurst_ReadStop ( TIM_HandleTypeDef htim,
uint32_t  BurstRequestSrc 
)

Stop the DMA burst reading.

Parameters
htimTIM handle
BurstRequestSrcTIM DMA Request sources to disable.
Return values
HALstatus

Definition at line 4332 of file stm32l4xx_hal_tim.c.

4333 {
4334  HAL_StatusTypeDef status = HAL_OK;
4335  /* Check the parameters */
4336  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4337 
4338  /* Abort the DMA transfer (at least disable the DMA channel) */
4339  switch (BurstRequestSrc)
4340  {
4341  case TIM_DMA_UPDATE:
4342  {
4343  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
4344  break;
4345  }
4346  case TIM_DMA_CC1:
4347  {
4348  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
4349  break;
4350  }
4351  case TIM_DMA_CC2:
4352  {
4353  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
4354  break;
4355  }
4356  case TIM_DMA_CC3:
4357  {
4358  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
4359  break;
4360  }
4361  case TIM_DMA_CC4:
4362  {
4363  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
4364  break;
4365  }
4366  case TIM_DMA_COM:
4367  {
4368  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
4369  break;
4370  }
4371  case TIM_DMA_TRIGGER:
4372  {
4373  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
4374  break;
4375  }
4376  default:
4377  break;
4378  }
4379 
4380  if (HAL_OK == status)
4381  {
4382  /* Disable the TIM Update DMA request */
4383  __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
4384  }
4385 
4386  /* Return function status */
4387  return status;
4388 }
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_DMABurst_WriteStart()

HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStart ( TIM_HandleTypeDef htim,
uint32_t  BurstBaseAddress,
uint32_t  BurstRequestSrc,
uint32_t *  BurstBuffer,
uint32_t  BurstLength 
)

Configure the DMA Burst to transfer Data from the memory to the TIM peripheral.

Parameters
htimTIM handle
BurstBaseAddressTIM Base address from where the DMA will start the Data write This parameter can be one of the following values:
  • TIM_DMABASE_CR1
  • TIM_DMABASE_CR2
  • TIM_DMABASE_SMCR
  • TIM_DMABASE_DIER
  • TIM_DMABASE_SR
  • TIM_DMABASE_EGR
  • TIM_DMABASE_CCMR1
  • TIM_DMABASE_CCMR2
  • TIM_DMABASE_CCER
  • TIM_DMABASE_CNT
  • TIM_DMABASE_PSC
  • TIM_DMABASE_ARR
  • TIM_DMABASE_RCR
  • TIM_DMABASE_CCR1
  • TIM_DMABASE_CCR2
  • TIM_DMABASE_CCR3
  • TIM_DMABASE_CCR4
  • TIM_DMABASE_BDTR
  • TIM_DMABASE_OR1
  • TIM_DMABASE_CCMR3
  • TIM_DMABASE_CCR5
  • TIM_DMABASE_CCR6
  • TIM_DMABASE_OR2
  • TIM_DMABASE_OR3
BurstRequestSrcTIM DMA Request sources This parameter can be one of the following values:
  • TIM_DMA_UPDATE: TIM update Interrupt source
  • TIM_DMA_CC1: TIM Capture Compare 1 DMA source
  • TIM_DMA_CC2: TIM Capture Compare 2 DMA source
  • TIM_DMA_CC3: TIM Capture Compare 3 DMA source
  • TIM_DMA_CC4: TIM Capture Compare 4 DMA source
  • TIM_DMA_COM: TIM Commutation DMA source
  • TIM_DMA_TRIGGER: TIM Trigger DMA source
BurstBufferThe Buffer address.
BurstLengthDMA Burst length. This parameter can be one value between: TIM_DMABURSTLENGTH_1TRANSFER and TIM_DMABURSTLENGTH_18TRANSFERS.
Note
This function should be used only when BurstLength is equal to DMA data transfer length.
Return values
HALstatus

Definition at line 3897 of file stm32l4xx_hal_tim.c.

3899 {
3900  /* Check the parameters */
3901  assert_param(IS_TIM_DMABURST_INSTANCE(htim->Instance));
3902  assert_param(IS_TIM_DMA_BASE(BurstBaseAddress));
3903  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
3904  assert_param(IS_TIM_DMA_LENGTH(BurstLength));
3905 
3906  if ((htim->State == HAL_TIM_STATE_BUSY))
3907  {
3908  return HAL_BUSY;
3909  }
3910  else if ((htim->State == HAL_TIM_STATE_READY))
3911  {
3912  if ((BurstBuffer == NULL) && (BurstLength > 0U))
3913  {
3914  return HAL_ERROR;
3915  }
3916  else
3917  {
3918  htim->State = HAL_TIM_STATE_BUSY;
3919  }
3920  }
3921  else
3922  {
3923  /* nothing to do */
3924  }
3925  switch (BurstRequestSrc)
3926  {
3927  case TIM_DMA_UPDATE:
3928  {
3929  /* Set the DMA Period elapsed callbacks */
3930  htim->hdma[TIM_DMA_ID_UPDATE]->XferCpltCallback = TIM_DMAPeriodElapsedCplt;
3931  htim->hdma[TIM_DMA_ID_UPDATE]->XferHalfCpltCallback = TIM_DMAPeriodElapsedHalfCplt;
3932 
3933  /* Set the DMA error callback */
3934  htim->hdma[TIM_DMA_ID_UPDATE]->XferErrorCallback = TIM_DMAError ;
3935 
3936  /* Enable the DMA channel */
3937  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_UPDATE], (uint32_t)BurstBuffer, (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
3938  {
3939  return HAL_ERROR;
3940  }
3941  break;
3942  }
3943  case TIM_DMA_CC1:
3944  {
3945  /* Set the DMA compare callbacks */
3946  htim->hdma[TIM_DMA_ID_CC1]->XferCpltCallback = TIM_DMADelayPulseCplt;
3947  htim->hdma[TIM_DMA_ID_CC1]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
3948 
3949  /* Set the DMA error callback */
3950  htim->hdma[TIM_DMA_ID_CC1]->XferErrorCallback = TIM_DMAError ;
3951 
3952  /* Enable the DMA channel */
3953  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC1], (uint32_t)BurstBuffer,
3954  (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
3955  {
3956  return HAL_ERROR;
3957  }
3958  break;
3959  }
3960  case TIM_DMA_CC2:
3961  {
3962  /* Set the DMA compare callbacks */
3963  htim->hdma[TIM_DMA_ID_CC2]->XferCpltCallback = TIM_DMADelayPulseCplt;
3964  htim->hdma[TIM_DMA_ID_CC2]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
3965 
3966  /* Set the DMA error callback */
3967  htim->hdma[TIM_DMA_ID_CC2]->XferErrorCallback = TIM_DMAError ;
3968 
3969  /* Enable the DMA channel */
3970  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC2], (uint32_t)BurstBuffer,
3971  (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
3972  {
3973  return HAL_ERROR;
3974  }
3975  break;
3976  }
3977  case TIM_DMA_CC3:
3978  {
3979  /* Set the DMA compare callbacks */
3980  htim->hdma[TIM_DMA_ID_CC3]->XferCpltCallback = TIM_DMADelayPulseCplt;
3981  htim->hdma[TIM_DMA_ID_CC3]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
3982 
3983  /* Set the DMA error callback */
3984  htim->hdma[TIM_DMA_ID_CC3]->XferErrorCallback = TIM_DMAError ;
3985 
3986  /* Enable the DMA channel */
3987  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC3], (uint32_t)BurstBuffer,
3988  (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
3989  {
3990  return HAL_ERROR;
3991  }
3992  break;
3993  }
3994  case TIM_DMA_CC4:
3995  {
3996  /* Set the DMA compare callbacks */
3997  htim->hdma[TIM_DMA_ID_CC4]->XferCpltCallback = TIM_DMADelayPulseCplt;
3998  htim->hdma[TIM_DMA_ID_CC4]->XferHalfCpltCallback = TIM_DMADelayPulseHalfCplt;
3999 
4000  /* Set the DMA error callback */
4001  htim->hdma[TIM_DMA_ID_CC4]->XferErrorCallback = TIM_DMAError ;
4002 
4003  /* Enable the DMA channel */
4004  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_CC4], (uint32_t)BurstBuffer,
4005  (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4006  {
4007  return HAL_ERROR;
4008  }
4009  break;
4010  }
4011  case TIM_DMA_COM:
4012  {
4013  /* Set the DMA commutation callbacks */
4014  htim->hdma[TIM_DMA_ID_COMMUTATION]->XferCpltCallback = TIMEx_DMACommutationCplt;
4015  htim->hdma[TIM_DMA_ID_COMMUTATION]->XferHalfCpltCallback = TIMEx_DMACommutationHalfCplt;
4016 
4017  /* Set the DMA error callback */
4018  htim->hdma[TIM_DMA_ID_COMMUTATION]->XferErrorCallback = TIM_DMAError ;
4019 
4020  /* Enable the DMA channel */
4021  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_COMMUTATION], (uint32_t)BurstBuffer,
4022  (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4023  {
4024  return HAL_ERROR;
4025  }
4026  break;
4027  }
4028  case TIM_DMA_TRIGGER:
4029  {
4030  /* Set the DMA trigger callbacks */
4031  htim->hdma[TIM_DMA_ID_TRIGGER]->XferCpltCallback = TIM_DMATriggerCplt;
4032  htim->hdma[TIM_DMA_ID_TRIGGER]->XferHalfCpltCallback = TIM_DMATriggerHalfCplt;
4033 
4034  /* Set the DMA error callback */
4035  htim->hdma[TIM_DMA_ID_TRIGGER]->XferErrorCallback = TIM_DMAError ;
4036 
4037  /* Enable the DMA channel */
4038  if (HAL_DMA_Start_IT(htim->hdma[TIM_DMA_ID_TRIGGER], (uint32_t)BurstBuffer,
4039  (uint32_t)&htim->Instance->DMAR, ((BurstLength) >> 8U) + 1U) != HAL_OK)
4040  {
4041  return HAL_ERROR;
4042  }
4043  break;
4044  }
4045  default:
4046  break;
4047  }
4048  /* configure the DMA Burst Mode */
4049  htim->Instance->DCR = (BurstBaseAddress | BurstLength);
4050 
4051  /* Enable the TIM DMA Request */
4052  __HAL_TIM_ENABLE_DMA(htim, BurstRequestSrc);
4053 
4054  htim->State = HAL_TIM_STATE_READY;
4055 
4056  /* Return function status */
4057  return HAL_OK;
4058 }
void TIMEx_DMACommutationHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Commutation half complete callback.
static void TIM_DMAPeriodElapsedHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Period Elapse half complete callback.
void TIM_DMADelayPulseCplt(DMA_HandleTypeDef *hdma)
TIM DMA Delay Pulse complete callback.
void TIM_DMADelayPulseHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Delay Pulse half complete callback.
HAL_StatusTypeDef HAL_DMA_Start_IT(DMA_HandleTypeDef *hdma, uint32_t SrcAddress, uint32_t DstAddress, uint32_t DataLength)
Start the DMA Transfer with interrupt enabled.
void TIM_DMAError(DMA_HandleTypeDef *hdma)
TIM DMA error callback.
return HAL_OK
static void TIM_DMATriggerHalfCplt(DMA_HandleTypeDef *hdma)
TIM DMA Trigger half complete callback.
static void TIM_DMATriggerCplt(DMA_HandleTypeDef *hdma)
TIM DMA Trigger callback.
static void TIM_DMAPeriodElapsedCplt(DMA_HandleTypeDef *hdma)
TIM DMA Period Elapse complete callback.
void TIMEx_DMACommutationCplt(DMA_HandleTypeDef *hdma)
TIM DMA Commutation callback.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_DMABurst_WriteStop()

HAL_StatusTypeDef HAL_TIM_DMABurst_WriteStop ( TIM_HandleTypeDef htim,
uint32_t  BurstRequestSrc 
)

Stops the TIM DMA Burst mode.

Parameters
htimTIM handle
BurstRequestSrcTIM DMA Request sources to disable
Return values
HALstatus

Definition at line 4066 of file stm32l4xx_hal_tim.c.

4067 {
4068  HAL_StatusTypeDef status = HAL_OK;
4069  /* Check the parameters */
4070  assert_param(IS_TIM_DMA_SOURCE(BurstRequestSrc));
4071 
4072  /* Abort the DMA transfer (at least disable the DMA channel) */
4073  switch (BurstRequestSrc)
4074  {
4075  case TIM_DMA_UPDATE:
4076  {
4077  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_UPDATE]);
4078  break;
4079  }
4080  case TIM_DMA_CC1:
4081  {
4082  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC1]);
4083  break;
4084  }
4085  case TIM_DMA_CC2:
4086  {
4087  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC2]);
4088  break;
4089  }
4090  case TIM_DMA_CC3:
4091  {
4092  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC3]);
4093  break;
4094  }
4095  case TIM_DMA_CC4:
4096  {
4097  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_CC4]);
4098  break;
4099  }
4100  case TIM_DMA_COM:
4101  {
4102  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_COMMUTATION]);
4103  break;
4104  }
4105  case TIM_DMA_TRIGGER:
4106  {
4107  status = HAL_DMA_Abort_IT(htim->hdma[TIM_DMA_ID_TRIGGER]);
4108  break;
4109  }
4110  default:
4111  break;
4112  }
4113 
4114  if (HAL_OK == status)
4115  {
4116  /* Disable the TIM Update DMA request */
4117  __HAL_TIM_DISABLE_DMA(htim, BurstRequestSrc);
4118  }
4119 
4120  /* Return function status */
4121  return status;
4122 }
HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma)
Aborts the DMA Transfer in Interrupt mode.
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_GenerateEvent()

HAL_StatusTypeDef HAL_TIM_GenerateEvent ( TIM_HandleTypeDef htim,
uint32_t  EventSource 
)

Generate a software event.

Parameters
htimTIM handle
EventSourcespecifies the event source. This parameter can be one of the following values:
  • TIM_EVENTSOURCE_UPDATE: Timer update Event source
  • TIM_EVENTSOURCE_CC1: Timer Capture Compare 1 Event source
  • TIM_EVENTSOURCE_CC2: Timer Capture Compare 2 Event source
  • TIM_EVENTSOURCE_CC3: Timer Capture Compare 3 Event source
  • TIM_EVENTSOURCE_CC4: Timer Capture Compare 4 Event source
  • TIM_EVENTSOURCE_COM: Timer COM event source
  • TIM_EVENTSOURCE_TRIGGER: Timer Trigger Event source
  • TIM_EVENTSOURCE_BREAK: Timer Break event source
  • TIM_EVENTSOURCE_BREAK2: Timer Break2 event source
Note
Basic timers can only generate an update event.
TIM_EVENTSOURCE_COM is relevant only with advanced timer instances.
TIM_EVENTSOURCE_BREAK and TIM_EVENTSOURCE_BREAK2 are relevant only for timer instances supporting break input(s).
Return values
HALstatus

Definition at line 4411 of file stm32l4xx_hal_tim.c.

4412 {
4413  /* Check the parameters */
4414  assert_param(IS_TIM_INSTANCE(htim->Instance));
4415  assert_param(IS_TIM_EVENT_SOURCE(EventSource));
4416 
4417  /* Process Locked */
4418  __HAL_LOCK(htim);
4419 
4420  /* Change the TIM state */
4421  htim->State = HAL_TIM_STATE_BUSY;
4422 
4423  /* Set the event sources */
4424  htim->Instance->EGR = EventSource;
4425 
4426  /* Change the TIM state */
4427  htim->State = HAL_TIM_STATE_READY;
4428 
4429  __HAL_UNLOCK(htim);
4430 
4431  /* Return function status */
4432  return HAL_OK;
4433 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_IC_ConfigChannel()

HAL_StatusTypeDef HAL_TIM_IC_ConfigChannel ( TIM_HandleTypeDef htim,
TIM_IC_InitTypeDef sConfig,
uint32_t  Channel 
)

Initializes the TIM Input Capture Channels according to the specified parameters in the TIM_IC_InitTypeDef.

Parameters
htimTIM IC handle
sConfigTIM Input Capture configuration structure
ChannelTIM Channel to configure This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
  • TIM_CHANNEL_3: TIM Channel 3 selected
  • TIM_CHANNEL_4: TIM Channel 4 selected
Return values
HALstatus

Definition at line 3508 of file stm32l4xx_hal_tim.c.

3509 {
3510  /* Check the parameters */
3511  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3512  assert_param(IS_TIM_IC_POLARITY(sConfig->ICPolarity));
3513  assert_param(IS_TIM_IC_SELECTION(sConfig->ICSelection));
3514  assert_param(IS_TIM_IC_PRESCALER(sConfig->ICPrescaler));
3515  assert_param(IS_TIM_IC_FILTER(sConfig->ICFilter));
3516 
3517  /* Process Locked */
3518  __HAL_LOCK(htim);
3519 
3520  htim->State = HAL_TIM_STATE_BUSY;
3521 
3522  if (Channel == TIM_CHANNEL_1)
3523  {
3524  /* TI1 Configuration */
3525  TIM_TI1_SetConfig(htim->Instance,
3526  sConfig->ICPolarity,
3527  sConfig->ICSelection,
3528  sConfig->ICFilter);
3529 
3530  /* Reset the IC1PSC Bits */
3531  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
3532 
3533  /* Set the IC1PSC value */
3534  htim->Instance->CCMR1 |= sConfig->ICPrescaler;
3535  }
3536  else if (Channel == TIM_CHANNEL_2)
3537  {
3538  /* TI2 Configuration */
3539  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3540 
3541  TIM_TI2_SetConfig(htim->Instance,
3542  sConfig->ICPolarity,
3543  sConfig->ICSelection,
3544  sConfig->ICFilter);
3545 
3546  /* Reset the IC2PSC Bits */
3547  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
3548 
3549  /* Set the IC2PSC value */
3550  htim->Instance->CCMR1 |= (sConfig->ICPrescaler << 8U);
3551  }
3552  else if (Channel == TIM_CHANNEL_3)
3553  {
3554  /* TI3 Configuration */
3555  assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
3556 
3557  TIM_TI3_SetConfig(htim->Instance,
3558  sConfig->ICPolarity,
3559  sConfig->ICSelection,
3560  sConfig->ICFilter);
3561 
3562  /* Reset the IC3PSC Bits */
3563  htim->Instance->CCMR2 &= ~TIM_CCMR2_IC3PSC;
3564 
3565  /* Set the IC3PSC value */
3566  htim->Instance->CCMR2 |= sConfig->ICPrescaler;
3567  }
3568  else
3569  {
3570  /* TI4 Configuration */
3571  assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
3572 
3573  TIM_TI4_SetConfig(htim->Instance,
3574  sConfig->ICPolarity,
3575  sConfig->ICSelection,
3576  sConfig->ICFilter);
3577 
3578  /* Reset the IC4PSC Bits */
3579  htim->Instance->CCMR2 &= ~TIM_CCMR2_IC4PSC;
3580 
3581  /* Set the IC4PSC value */
3582  htim->Instance->CCMR2 |= (sConfig->ICPrescaler << 8U);
3583  }
3584 
3585  htim->State = HAL_TIM_STATE_READY;
3586 
3587  __HAL_UNLOCK(htim);
3588 
3589  return HAL_OK;
3590 }
void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
Configure the TI1 as Input.
static void TIM_TI3_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
Configure the TI3 as Input.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
Configure the TI2 as Input.
static void TIM_TI4_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
Configure the TI4 as Input.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_OC_ConfigChannel()

HAL_StatusTypeDef HAL_TIM_OC_ConfigChannel ( TIM_HandleTypeDef htim,
TIM_OC_InitTypeDef sConfig,
uint32_t  Channel 
)

Initializes the TIM Output Compare Channels according to the specified parameters in the TIM_OC_InitTypeDef.

Parameters
htimTIM Output Compare handle
sConfigTIM Output Compare configuration structure
ChannelTIM Channels to configure This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
  • TIM_CHANNEL_3: TIM Channel 3 selected
  • TIM_CHANNEL_4: TIM Channel 4 selected
  • TIM_CHANNEL_5: TIM Channel 5 selected
  • TIM_CHANNEL_6: TIM Channel 6 selected
Return values
HALstatus

Definition at line 3408 of file stm32l4xx_hal_tim.c.

3411 {
3412  /* Check the parameters */
3413  assert_param(IS_TIM_CHANNELS(Channel));
3414  assert_param(IS_TIM_OC_MODE(sConfig->OCMode));
3415  assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
3416 
3417  /* Process Locked */
3418  __HAL_LOCK(htim);
3419 
3420  htim->State = HAL_TIM_STATE_BUSY;
3421 
3422  switch (Channel)
3423  {
3424  case TIM_CHANNEL_1:
3425  {
3426  /* Check the parameters */
3427  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3428 
3429  /* Configure the TIM Channel 1 in Output Compare */
3430  TIM_OC1_SetConfig(htim->Instance, sConfig);
3431  break;
3432  }
3433 
3434  case TIM_CHANNEL_2:
3435  {
3436  /* Check the parameters */
3437  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3438 
3439  /* Configure the TIM Channel 2 in Output Compare */
3440  TIM_OC2_SetConfig(htim->Instance, sConfig);
3441  break;
3442  }
3443 
3444  case TIM_CHANNEL_3:
3445  {
3446  /* Check the parameters */
3447  assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
3448 
3449  /* Configure the TIM Channel 3 in Output Compare */
3450  TIM_OC3_SetConfig(htim->Instance, sConfig);
3451  break;
3452  }
3453 
3454  case TIM_CHANNEL_4:
3455  {
3456  /* Check the parameters */
3457  assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
3458 
3459  /* Configure the TIM Channel 4 in Output Compare */
3460  TIM_OC4_SetConfig(htim->Instance, sConfig);
3461  break;
3462  }
3463 
3464  case TIM_CHANNEL_5:
3465  {
3466  /* Check the parameters */
3467  assert_param(IS_TIM_CC5_INSTANCE(htim->Instance));
3468 
3469  /* Configure the TIM Channel 5 in Output Compare */
3470  TIM_OC5_SetConfig(htim->Instance, sConfig);
3471  break;
3472  }
3473 
3474  case TIM_CHANNEL_6:
3475  {
3476  /* Check the parameters */
3477  assert_param(IS_TIM_CC6_INSTANCE(htim->Instance));
3478 
3479  /* Configure the TIM Channel 6 in Output Compare */
3480  TIM_OC6_SetConfig(htim->Instance, sConfig);
3481  break;
3482  }
3483 
3484  default:
3485  break;
3486  }
3487 
3488  htim->State = HAL_TIM_STATE_READY;
3489 
3490  __HAL_UNLOCK(htim);
3491 
3492  return HAL_OK;
3493 }
static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 3 configuration.
static void TIM_OC5_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 5 configuration.
__HAL_UNLOCK(hrtc)
static void TIM_OC6_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 6 configuration.
__HAL_LOCK(hrtc)
static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 4 configuration.
return HAL_OK
void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 2 configuration.
static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 1 configuration.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_OnePulse_ConfigChannel()

HAL_StatusTypeDef HAL_TIM_OnePulse_ConfigChannel ( TIM_HandleTypeDef htim,
TIM_OnePulse_InitTypeDef sConfig,
uint32_t  OutputChannel,
uint32_t  InputChannel 
)

Initializes the TIM One Pulse Channels according to the specified parameters in the TIM_OnePulse_InitTypeDef.

Parameters
htimTIM One Pulse handle
sConfigTIM One Pulse configuration structure
OutputChannelTIM output channel to configure This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
InputChannelTIM input Channel to configure This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
Return values
HALstatus

Definition at line 3752 of file stm32l4xx_hal_tim.c.

3754 {
3755  TIM_OC_InitTypeDef temp1;
3756 
3757  /* Check the parameters */
3758  assert_param(IS_TIM_OPM_CHANNELS(OutputChannel));
3759  assert_param(IS_TIM_OPM_CHANNELS(InputChannel));
3760 
3761  if (OutputChannel != InputChannel)
3762  {
3763  /* Process Locked */
3764  __HAL_LOCK(htim);
3765 
3766  htim->State = HAL_TIM_STATE_BUSY;
3767 
3768  /* Extract the Output compare configuration from sConfig structure */
3769  temp1.OCMode = sConfig->OCMode;
3770  temp1.Pulse = sConfig->Pulse;
3771  temp1.OCPolarity = sConfig->OCPolarity;
3772  temp1.OCNPolarity = sConfig->OCNPolarity;
3773  temp1.OCIdleState = sConfig->OCIdleState;
3774  temp1.OCNIdleState = sConfig->OCNIdleState;
3775 
3776  switch (OutputChannel)
3777  {
3778  case TIM_CHANNEL_1:
3779  {
3780  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3781 
3782  TIM_OC1_SetConfig(htim->Instance, &temp1);
3783  break;
3784  }
3785  case TIM_CHANNEL_2:
3786  {
3787  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3788 
3789  TIM_OC2_SetConfig(htim->Instance, &temp1);
3790  break;
3791  }
3792  default:
3793  break;
3794  }
3795 
3796  switch (InputChannel)
3797  {
3798  case TIM_CHANNEL_1:
3799  {
3800  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3801 
3802  TIM_TI1_SetConfig(htim->Instance, sConfig->ICPolarity,
3803  sConfig->ICSelection, sConfig->ICFilter);
3804 
3805  /* Reset the IC1PSC Bits */
3806  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC1PSC;
3807 
3808  /* Select the Trigger source */
3809  htim->Instance->SMCR &= ~TIM_SMCR_TS;
3810  htim->Instance->SMCR |= TIM_TS_TI1FP1;
3811 
3812  /* Select the Slave Mode */
3813  htim->Instance->SMCR &= ~TIM_SMCR_SMS;
3814  htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
3815  break;
3816  }
3817  case TIM_CHANNEL_2:
3818  {
3819  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3820 
3821  TIM_TI2_SetConfig(htim->Instance, sConfig->ICPolarity,
3822  sConfig->ICSelection, sConfig->ICFilter);
3823 
3824  /* Reset the IC2PSC Bits */
3825  htim->Instance->CCMR1 &= ~TIM_CCMR1_IC2PSC;
3826 
3827  /* Select the Trigger source */
3828  htim->Instance->SMCR &= ~TIM_SMCR_TS;
3829  htim->Instance->SMCR |= TIM_TS_TI2FP2;
3830 
3831  /* Select the Slave Mode */
3832  htim->Instance->SMCR &= ~TIM_SMCR_SMS;
3833  htim->Instance->SMCR |= TIM_SLAVEMODE_TRIGGER;
3834  break;
3835  }
3836 
3837  default:
3838  break;
3839  }
3840 
3841  htim->State = HAL_TIM_STATE_READY;
3842 
3843  __HAL_UNLOCK(htim);
3844 
3845  return HAL_OK;
3846  }
3847  else
3848  {
3849  return HAL_ERROR;
3850  }
3851 }
void TIM_TI1_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
Configure the TI1 as Input.
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
static void TIM_TI2_SetConfig(TIM_TypeDef *TIMx, uint32_t TIM_ICPolarity, uint32_t TIM_ICSelection, uint32_t TIM_ICFilter)
Configure the TI2 as Input.
TIM Output Compare Configuration Structure definition.
void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 2 configuration.
static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 1 configuration.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_PWM_ConfigChannel()

HAL_StatusTypeDef HAL_TIM_PWM_ConfigChannel ( TIM_HandleTypeDef htim,
TIM_OC_InitTypeDef sConfig,
uint32_t  Channel 
)

Initializes the TIM PWM channels according to the specified parameters in the TIM_OC_InitTypeDef.

Parameters
htimTIM PWM handle
sConfigTIM PWM configuration structure
ChannelTIM Channels to be configured This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
  • TIM_CHANNEL_3: TIM Channel 3 selected
  • TIM_CHANNEL_4: TIM Channel 4 selected
  • TIM_CHANNEL_5: TIM Channel 5 selected
  • TIM_CHANNEL_6: TIM Channel 6 selected
Return values
HALstatus

Definition at line 3607 of file stm32l4xx_hal_tim.c.

3610 {
3611  /* Check the parameters */
3612  assert_param(IS_TIM_CHANNELS(Channel));
3613  assert_param(IS_TIM_PWM_MODE(sConfig->OCMode));
3614  assert_param(IS_TIM_OC_POLARITY(sConfig->OCPolarity));
3615  assert_param(IS_TIM_FAST_STATE(sConfig->OCFastMode));
3616 
3617  /* Process Locked */
3618  __HAL_LOCK(htim);
3619 
3620  htim->State = HAL_TIM_STATE_BUSY;
3621 
3622  switch (Channel)
3623  {
3624  case TIM_CHANNEL_1:
3625  {
3626  /* Check the parameters */
3627  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
3628 
3629  /* Configure the Channel 1 in PWM mode */
3630  TIM_OC1_SetConfig(htim->Instance, sConfig);
3631 
3632  /* Set the Preload enable bit for channel1 */
3633  htim->Instance->CCMR1 |= TIM_CCMR1_OC1PE;
3634 
3635  /* Configure the Output Fast mode */
3636  htim->Instance->CCMR1 &= ~TIM_CCMR1_OC1FE;
3637  htim->Instance->CCMR1 |= sConfig->OCFastMode;
3638  break;
3639  }
3640 
3641  case TIM_CHANNEL_2:
3642  {
3643  /* Check the parameters */
3644  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
3645 
3646  /* Configure the Channel 2 in PWM mode */
3647  TIM_OC2_SetConfig(htim->Instance, sConfig);
3648 
3649  /* Set the Preload enable bit for channel2 */
3650  htim->Instance->CCMR1 |= TIM_CCMR1_OC2PE;
3651 
3652  /* Configure the Output Fast mode */
3653  htim->Instance->CCMR1 &= ~TIM_CCMR1_OC2FE;
3654  htim->Instance->CCMR1 |= sConfig->OCFastMode << 8U;
3655  break;
3656  }
3657 
3658  case TIM_CHANNEL_3:
3659  {
3660  /* Check the parameters */
3661  assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
3662 
3663  /* Configure the Channel 3 in PWM mode */
3664  TIM_OC3_SetConfig(htim->Instance, sConfig);
3665 
3666  /* Set the Preload enable bit for channel3 */
3667  htim->Instance->CCMR2 |= TIM_CCMR2_OC3PE;
3668 
3669  /* Configure the Output Fast mode */
3670  htim->Instance->CCMR2 &= ~TIM_CCMR2_OC3FE;
3671  htim->Instance->CCMR2 |= sConfig->OCFastMode;
3672  break;
3673  }
3674 
3675  case TIM_CHANNEL_4:
3676  {
3677  /* Check the parameters */
3678  assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
3679 
3680  /* Configure the Channel 4 in PWM mode */
3681  TIM_OC4_SetConfig(htim->Instance, sConfig);
3682 
3683  /* Set the Preload enable bit for channel4 */
3684  htim->Instance->CCMR2 |= TIM_CCMR2_OC4PE;
3685 
3686  /* Configure the Output Fast mode */
3687  htim->Instance->CCMR2 &= ~TIM_CCMR2_OC4FE;
3688  htim->Instance->CCMR2 |= sConfig->OCFastMode << 8U;
3689  break;
3690  }
3691 
3692  case TIM_CHANNEL_5:
3693  {
3694  /* Check the parameters */
3695  assert_param(IS_TIM_CC5_INSTANCE(htim->Instance));
3696 
3697  /* Configure the Channel 5 in PWM mode */
3698  TIM_OC5_SetConfig(htim->Instance, sConfig);
3699 
3700  /* Set the Preload enable bit for channel5*/
3701  htim->Instance->CCMR3 |= TIM_CCMR3_OC5PE;
3702 
3703  /* Configure the Output Fast mode */
3704  htim->Instance->CCMR3 &= ~TIM_CCMR3_OC5FE;
3705  htim->Instance->CCMR3 |= sConfig->OCFastMode;
3706  break;
3707  }
3708 
3709  case TIM_CHANNEL_6:
3710  {
3711  /* Check the parameters */
3712  assert_param(IS_TIM_CC6_INSTANCE(htim->Instance));
3713 
3714  /* Configure the Channel 6 in PWM mode */
3715  TIM_OC6_SetConfig(htim->Instance, sConfig);
3716 
3717  /* Set the Preload enable bit for channel6 */
3718  htim->Instance->CCMR3 |= TIM_CCMR3_OC6PE;
3719 
3720  /* Configure the Output Fast mode */
3721  htim->Instance->CCMR3 &= ~TIM_CCMR3_OC6FE;
3722  htim->Instance->CCMR3 |= sConfig->OCFastMode << 8U;
3723  break;
3724  }
3725 
3726  default:
3727  break;
3728  }
3729 
3730  htim->State = HAL_TIM_STATE_READY;
3731 
3732  __HAL_UNLOCK(htim);
3733 
3734  return HAL_OK;
3735 }
static void TIM_OC3_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 3 configuration.
static void TIM_OC5_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 5 configuration.
__HAL_UNLOCK(hrtc)
static void TIM_OC6_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 6 configuration.
__HAL_LOCK(hrtc)
static void TIM_OC4_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 4 configuration.
return HAL_OK
void TIM_OC2_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 2 configuration.
static void TIM_OC1_SetConfig(TIM_TypeDef *TIMx, TIM_OC_InitTypeDef *OC_Config)
Timer Output Compare 1 configuration.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_ReadCapturedValue()

uint32_t HAL_TIM_ReadCapturedValue ( TIM_HandleTypeDef htim,
uint32_t  Channel 
)

Read the captured value from Capture Compare unit.

Parameters
htimTIM handle.
ChannelTIM Channels to be enabled This parameter can be one of the following values:
  • TIM_CHANNEL_1: TIM Channel 1 selected
  • TIM_CHANNEL_2: TIM Channel 2 selected
  • TIM_CHANNEL_3: TIM Channel 3 selected
  • TIM_CHANNEL_4: TIM Channel 4 selected
Return values
Capturedvalue

Definition at line 4878 of file stm32l4xx_hal_tim.c.

4879 {
4880  uint32_t tmpreg = 0U;
4881 
4882  switch (Channel)
4883  {
4884  case TIM_CHANNEL_1:
4885  {
4886  /* Check the parameters */
4887  assert_param(IS_TIM_CC1_INSTANCE(htim->Instance));
4888 
4889  /* Return the capture 1 value */
4890  tmpreg = htim->Instance->CCR1;
4891 
4892  break;
4893  }
4894  case TIM_CHANNEL_2:
4895  {
4896  /* Check the parameters */
4897  assert_param(IS_TIM_CC2_INSTANCE(htim->Instance));
4898 
4899  /* Return the capture 2 value */
4900  tmpreg = htim->Instance->CCR2;
4901 
4902  break;
4903  }
4904 
4905  case TIM_CHANNEL_3:
4906  {
4907  /* Check the parameters */
4908  assert_param(IS_TIM_CC3_INSTANCE(htim->Instance));
4909 
4910  /* Return the capture 3 value */
4911  tmpreg = htim->Instance->CCR3;
4912 
4913  break;
4914  }
4915 
4916  case TIM_CHANNEL_4:
4917  {
4918  /* Check the parameters */
4919  assert_param(IS_TIM_CC4_INSTANCE(htim->Instance));
4920 
4921  /* Return the capture 4 value */
4922  tmpreg = htim->Instance->CCR4;
4923 
4924  break;
4925  }
4926 
4927  default:
4928  break;
4929  }
4930 
4931  return tmpreg;
4932 }
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_SlaveConfigSynchro()

HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro ( TIM_HandleTypeDef htim,
TIM_SlaveConfigTypeDef sSlaveConfig 
)

Configures the TIM in Slave mode.

Parameters
htimTIM handle.
sSlaveConfigpointer to a TIM_SlaveConfigTypeDef structure that contains the selected trigger (internal trigger input, filtered timer input or external trigger input) and the Slave mode (Disable, Reset, Gated, Trigger, External clock mode 1).
Return values
HALstatus

Definition at line 4795 of file stm32l4xx_hal_tim.c.

4796 {
4797  /* Check the parameters */
4798  assert_param(IS_TIM_SLAVE_INSTANCE(htim->Instance));
4799  assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
4800  assert_param(IS_TIM_TRIGGER_SELECTION(sSlaveConfig->InputTrigger));
4801 
4802  __HAL_LOCK(htim);
4803 
4804  htim->State = HAL_TIM_STATE_BUSY;
4805 
4806  if (TIM_SlaveTimer_SetConfig(htim, sSlaveConfig) != HAL_OK)
4807  {
4808  htim->State = HAL_TIM_STATE_READY;
4809  __HAL_UNLOCK(htim);
4810  return HAL_ERROR;
4811  }
4812 
4813  /* Disable Trigger Interrupt */
4814  __HAL_TIM_DISABLE_IT(htim, TIM_IT_TRIGGER);
4815 
4816  /* Disable Trigger DMA request */
4817  __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_TRIGGER);
4818 
4819  htim->State = HAL_TIM_STATE_READY;
4820 
4821  __HAL_UNLOCK(htim);
4822 
4823  return HAL_OK;
4824 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
Slave Timer configuration function.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))

◆ HAL_TIM_SlaveConfigSynchro_IT()

HAL_StatusTypeDef HAL_TIM_SlaveConfigSynchro_IT ( TIM_HandleTypeDef htim,
TIM_SlaveConfigTypeDef sSlaveConfig 
)

Configures the TIM in Slave mode in interrupt mode.

Parameters
htimTIM handle.
sSlaveConfigpointer to a TIM_SlaveConfigTypeDef structure that contains the selected trigger (internal trigger input, filtered timer input or external trigger input) and the Slave mode (Disable, Reset, Gated, Trigger, External clock mode 1).
Return values
HALstatus

Definition at line 4835 of file stm32l4xx_hal_tim.c.

4837 {
4838  /* Check the parameters */
4839  assert_param(IS_TIM_SLAVE_INSTANCE(htim->Instance));
4840  assert_param(IS_TIM_SLAVE_MODE(sSlaveConfig->SlaveMode));
4841  assert_param(IS_TIM_TRIGGER_SELECTION(sSlaveConfig->InputTrigger));
4842 
4843  __HAL_LOCK(htim);
4844 
4845  htim->State = HAL_TIM_STATE_BUSY;
4846 
4847  if (TIM_SlaveTimer_SetConfig(htim, sSlaveConfig) != HAL_OK)
4848  {
4849  htim->State = HAL_TIM_STATE_READY;
4850  __HAL_UNLOCK(htim);
4851  return HAL_ERROR;
4852  }
4853 
4854  /* Enable Trigger Interrupt */
4855  __HAL_TIM_ENABLE_IT(htim, TIM_IT_TRIGGER);
4856 
4857  /* Disable Trigger DMA request */
4858  __HAL_TIM_DISABLE_DMA(htim, TIM_DMA_TRIGGER);
4859 
4860  htim->State = HAL_TIM_STATE_READY;
4861 
4862  __HAL_UNLOCK(htim);
4863 
4864  return HAL_OK;
4865 }
__HAL_UNLOCK(hrtc)
__HAL_LOCK(hrtc)
return HAL_OK
static HAL_StatusTypeDef TIM_SlaveTimer_SetConfig(TIM_HandleTypeDef *htim, TIM_SlaveConfigTypeDef *sSlaveConfig)
Slave Timer configuration function.
assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock))