⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stm32f10x_tim1.lst

📁 完成数据的采集
💻 LST
📖 第 1 页 / 共 5 页
字号:
    850              TIM1->DIER |= TIM1_IT;
    851            }
    852            else
    853            {
    854              /* Disable the Interrupt sources */
    855              TIM1->DIER &= (u16)~TIM1_IT;
    856            }
    857          }
    858          
    859          /*******************************************************************************
    860          * Function Name  : TIM1_DMAConfig
    861          * Description    : Configures the TIM1抯 DMA interface.
    862          * Input          : - TIM1_DMABase: DMA Base address.
    863          *                    This parameter can be one of the following values:
    864          *                       - TIM1_DMABase_CR1, TIM1_DMABase_CR2, TIM1_DMABase_SMCR,
    865          *                         TIM1_DMABase_DIER, TIM1_DMABase_SR, TIM1_DMABase_EGR,
    866          *                         TIM1_DMABase_CCMR1, TIM1_DMABase_CCMR2, TIM1_DMABase_CCER,
    867          *                         TIM1_DMABase_CNT, TIM1_DMABase_PSC, TIM1_DMABase_ARR,
    868          *                         TIM1_DMABase_RCR, TIM1_DMABase_CCR1, TIM1_DMABase_CCR2,
    869          *                         TIM1_DMABase_CCR3, TIM1_DMABase_CCR4, TIM1_DMABase_BDTR,
    870          *                         TIM1_DMABase_DCR.
    871          *                   - TIM1_DMABurstLength: DMA Burst length.
    872          *                     This parameter can be one value between:
    873          *                     TIM1_DMABurstLength_1Byte and TIM1_DMABurstLength_18Bytes.
    874          * Output         : None
    875          * Return         : None
    876          *******************************************************************************/
    877          void TIM1_DMAConfig(u16 TIM1_DMABase, u16 TIM1_DMABurstLength)
    878          {
    879            u32 tmpdcr = 0;
    880          
    881            /* Check the parameters */
    882            assert_param(IS_TIM1_DMA_BASE(TIM1_DMABase));
    883            assert_param(IS_TIM1_DMA_LENGTH(TIM1_DMABurstLength));
    884          
    885            tmpdcr = TIM1->DCR;
    886          
    887            /* Reset the DBA and the DBL Bits */
    888            tmpdcr &= DCR_DMA_Mask;
    889          
    890            /* Set the DMA Base and the DMA Burst Length */
    891            tmpdcr |= TIM1_DMABase | TIM1_DMABurstLength;
    892          
    893            TIM1->DCR = (u16)tmpdcr;
    894          }
    895          
    896          /*******************************************************************************
    897          * Function Name  : TIM1_DMACmd
    898          * Description    : Enables or disables the TIM1抯 DMA Requests.
    899          * Input          : - TIM1_DMASources: specifies the DMA Request sources.
    900          *                    This parameter can be any combination of the following values:
    901          *                       - TIM1_DMA_Update: TIM1 update Interrupt source
    902          *                       - TIM1_DMA_CC1: TIM1 Capture Compare 1 DMA source
    903          *                       - TIM1_DMA_CC2: TIM1 Capture Compare 2 DMA source
    904          *                       - TIM1_DMA_CC3: TIM1 Capture Compare 3 DMA source
    905          *                       - TIM1_DMA_CC4: TIM1 Capture Compare 4 DMA source
    906          *                       - TIM1_DMA_COM: TIM1 Capture Compare Update DMA
    907          *                         source
    908          *                       - TIM1_DMA_Trigger: TIM1 Trigger DMA source
    909          *                  - Newstate: new state of the DMA Request sources.
    910          *                    This parameter can be: ENABLE or DISABLE.
    911          * Output         : None
    912          * Return         : None
    913          *******************************************************************************/
    914          void TIM1_DMACmd(u16 TIM1_DMASource, FunctionalState Newstate)
    915          {
    916            u32 tmpdier = 0;
    917          
    918            /* Check the parameters */
    919            assert_param(IS_TIM1_DMA_SOURCE(TIM1_DMASource));
    920            assert_param(IS_FUNCTIONAL_STATE(Newstate));
    921          
    922            tmpdier = TIM1->DIER;
    923          
    924            if (Newstate == ENABLE)
    925            {
    926              /* Enable the DMA sources */
    927              tmpdier |= TIM1_DMASource;
    928            }
    929            else
    930            {
    931              /* Disable the DMA sources */
    932              tmpdier &= (u16)~TIM1_DMASource;
    933            }
    934            TIM1->DIER = (u16)tmpdier;
    935          }
    936          
    937          /*******************************************************************************
    938          * Function Name  : TIM1_InternalClockConfig
    939          * Description    : Configures the TIM1 interrnal Clock
    940          * Input          : None
    941          * Output         : None
    942          * Return         : None
    943          *******************************************************************************/
    944          void TIM1_InternalClockConfig(void)
    945          {
    946            /* Disable slave mode to clock the prescaler directly with the internal clock */
    947            TIM1->SMCR &=  SMCR_SMS_Mask;
    948          }
    949          /*******************************************************************************
    950          * Function Name  : TIM1_ETRClockMode1Config
    951          * Description    : Configures the TIM1 External clock Mode1
    952          * Input          : - TIM1_ExtTRGPrescaler: The external Trigger Prescaler.
    953          *                    It can be one of the following values:
    954          *                       - TIM1_ExtTRGPSC_OFF
    955          *                       - TIM1_ExtTRGPSC_DIV2
    956          *                       - TIM1_ExtTRGPSC_DIV4
    957          *                       - TIM1_ExtTRGPSC_DIV8.
    958          *                  - TIM1_ExtTRGPolarity: The external Trigger Polarity.
    959          *                    It can be one of the following values:
    960          *                       - TIM1_ExtTRGPolarity_Inverted
    961          *                       - TIM1_ExtTRGPolarity_NonInverted
    962          *                  - ExtTRGFilter: External Trigger Filter.
    963          *                    This parameter must be a value between 0x00 and 0x0F
    964          * Output         : None
    965          * Return         : None
    966          *******************************************************************************/
    967          void TIM1_ETRClockMode1Config(u16 TIM1_ExtTRGPrescaler, u16 TIM1_ExtTRGPolarity,
    968                                       u16 ExtTRGFilter)
    969          {
    970            /* Check the parameters */
    971            assert_param(IS_TIM1_EXT_PRESCALER(TIM1_ExtTRGPrescaler));
    972            assert_param(IS_TIM1_EXT_POLARITY(TIM1_ExtTRGPolarity));
    973          
    974            /* Configure the ETR Clock source */
    975            TIM1_ETRConfig(TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity, ExtTRGFilter);
    976          
    977            /* Select the External clock mode1 */
    978            TIM1->SMCR &= SMCR_SMS_Mask;
    979            TIM1->SMCR |= TIM1_SlaveMode_External1;
    980            
    981            /* Select the Trigger selection : ETRF */
    982            TIM1->SMCR &= SMCR_TS_Mask;
    983            TIM1->SMCR |= TIM1_TS_ETRF;
    984          }
    985          
    986          /*******************************************************************************
    987          * Function Name  : TIM1_ETRClockMode2Config
    988          * Description    : Configures the TIM1 External clock Mode2
    989          * Input          : - TIM1_ExtTRGPrescaler: The external Trigger Prescaler.
    990          *                    It can be one of the following values:
    991          *                       - TIM1_ExtTRGPSC_OFF
    992          *                       - TIM1_ExtTRGPSC_DIV2
    993          *                       - TIM1_ExtTRGPSC_DIV4
    994          *                       - TIM1_ExtTRGPSC_DIV8
    995          *                  - TIM1_ExtTRGPolarity: The external Trigger Polarity.
    996          *                    It can be one of the following values:
    997          *                       - TIM1_ExtTRGPolarity_Inverted
    998          *                       - TIM1_ExtTRGPolarity_NonInverted
    999          *                  - ExtTRGFilter: External Trigger Filter.
   1000          *                    This parameter must be a value between 0x00 and 0x0F
   1001          * Output         : None
   1002          * Return         : None
   1003          *******************************************************************************/
   1004          void TIM1_ETRClockMode2Config(u16 TIM1_ExtTRGPrescaler, u16 TIM1_ExtTRGPolarity,
   1005                                       u16 ExtTRGFilter)
   1006          {
   1007            /* Check the parameters */
   1008            assert_param(IS_TIM1_EXT_PRESCALER(TIM1_ExtTRGPrescaler));
   1009            assert_param(IS_TIM1_EXT_POLARITY(TIM1_ExtTRGPolarity));
   1010          
   1011            /* Configure the ETR Clock source */
   1012            TIM1_ETRConfig(TIM1_ExtTRGPrescaler, TIM1_ExtTRGPolarity, ExtTRGFilter);
   1013          
   1014            /* Enable the External clock mode2 */
   1015            *(vu32 *) SMCR_ECE_BB = SMCR_ECE_Set;
   1016          }
   1017          
   1018          /*******************************************************************************
   1019          * Function Name  : TIM1_ETRConfig
   1020          * Description    : Configures the TIM1 External Trigger (ETR).
   1021          * Input          : - TIM1_ExtTRGPrescaler: The external Trigger Prescaler.
   1022          *                    This parameter can be one of the following values:
   1023          *                       - TIM1_ExtTRGPSC_OFF
   1024          *                       - TIM1_ExtTRGPSC_DIV2
   1025          *                       - TIM1_ExtTRGPSC_DIV4
   1026          *                       - TIM1_ExtTRGPSC_DIV8
   1027          *                  - TIM1_ExtTRGPolarity: The external Trigger Polarity.
   1028          *                    This parameter can be one of the following values:
   1029          *                       - TIM1_ExtTRGPolarity_Inverted
   1030          *                       - TIM1_ExtTRGPolarity_NonInverted
   1031          *                  - ExtTRGFilter: External Trigger Filter.
   1032          *                    This parameter must be a value between 0x00 and 0x0F.
   1033          * Output         : None
   1034          * Return         : None
   1035          *******************************************************************************/
   1036          void TIM1_ETRConfig(u16 TIM1_ExtTRGPrescaler, u16 TIM1_ExtTRGPolarity,
   1037                              u16 ExtTRGFilter)
   1038          {
   1039            u32 tmpsmcr = 0;
   1040          
   1041            tmpsmcr = TIM1->SMCR;
   1042          
   1043            /* Set the Prescaler, the Filter value and the Polarity */
   1044            tmpsmcr &= SMCR_ETR_Mask;
   1045            tmpsmcr |= TIM1_ExtTRGPrescaler | TIM1_ExtTRGPolarity | (u16)((u16)ExtTRGFilter << 8);
   1046          
   1047            TIM1->SMCR = (u16)tmpsmcr;
   1048          }
   1049          
   1050          /*******************************************************************************
   1051          * Function Name  : TIM1_ITRxExternalClockConfig
   1052          * Description    : Configures the TIM1 Internal Trigger as External Clock
   1053          * Input          : - TIM1_ITRSource: Internal Trigger source.
   1054          *                    This parameter can be one of the following values:
   1055          *                       - TIM1_TS_ITR0: Internal Trigger 0
   1056          *                       - TIM1_TS_ITR1: Internal Trigger 1
   1057          *                       - TIM1_TS_ITR2: Internal Trigger 2
   1058          *                       - TIM1_TS_ITR3: Internal Trigger 3
   1059          * Output         : None
   1060          * Return         : None
   1061          *******************************************************************************/
   1062          void TIM1_ITRxExternalClockConfig(u16 TIM1_InputTriggerSource)
   1063          {
   1064            /* Check the parameters */
   1065            assert_param(IS_TIM1_INTERNAL_TRIGGER_SELECTION(TIM1_InputTriggerSource));
   1066   

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -