日本黄色一级经典视频|伊人久久精品视频|亚洲黄色色周成人视频九九九|av免费网址黄色小短片|黄色Av无码亚洲成年人|亚洲1区2区3区无码|真人黄片免费观看|无码一级小说欧美日免费三级|日韩中文字幕91在线看|精品久久久无码中文字幕边打电话

當(dāng)前位置:首頁 > 單片機(jī) > 單片機(jī)
[導(dǎo)讀]由于前面買的核心板,供電老有問題,使得我現(xiàn)在的項(xiàng)目又改用了以前用的F103ZET6微控制器!1、實(shí)驗(yàn)?zāi)康?)產(chǎn)生脈寬任意可調(diào)的單脈沖(在允許的范圍內(nèi))2、硬件:通用定時(shí)器3、通用定時(shí)器43、單脈沖模式介紹單脈沖模式

由于前面買的核心板,供電老有問題,使得我現(xiàn)在的項(xiàng)目又改用了以前用的F103ZET6微控制器!


1、實(shí)驗(yàn)?zāi)康?/p>

1)產(chǎn)生脈寬任意可調(diào)的單脈沖(在允許的范圍內(nèi))


2、硬件:通用定時(shí)器3、通用定時(shí)器4


3、單脈沖模式介紹

單脈沖模式允許計(jì)數(shù)器響應(yīng)一個(gè)激勵(lì),并在一個(gè)程序可控的延時(shí)之后,產(chǎn)生一個(gè)脈寬可程序控制的脈沖。

可以通過從模式控制器啟動(dòng)計(jì)數(shù)器,在輸出比較模式或者PWM模式下產(chǎn)生波形。設(shè)置TIMx_CR1 寄存器中的OPM 位將選擇單脈沖模式,這樣可以讓計(jì)數(shù)器自動(dòng)的產(chǎn)生下一個(gè)更新

事情UEV時(shí)停止。

僅當(dāng)比較值與計(jì)數(shù)器的初始值不同時(shí),才能產(chǎn)生一個(gè)脈沖。啟動(dòng)之前(當(dāng)定時(shí)器正在等待觸發(fā)),必須配置如下:

向上計(jì)數(shù)方式:CNT (計(jì)數(shù)器寄存器) < CCRx (比較寄存器)< ARR(自動(dòng)裝載寄存器)

向下計(jì)數(shù)方式:CNT > CCRx。


需要在從TI2輸入腳上檢測(cè)到一個(gè)上升沿開始,延遲tDELAY 之后,在OC1上產(chǎn)生一個(gè)長(zhǎng)度為tPULSE 的正脈沖。

具體的可以看參考手冊(cè)。


4、軟件設(shè)計(jì)


/**

******************************************************************************

*@filetimonepulse.c

*@authorCawen

*@versionV1.0

*@date2015-12-22

******************************************************************************

*/

/*Includes------------------------------------------------------------------*/

#include"timonepulse.h"

/*Privatevariables---------------------------------------------------------*/

uint16_tPrescalerValue=0;

/*

*FunctionName:GPIO_Configuration

*Description:ConfiguretheGPIODPins.

*Input:None

*Output:None

*Return:None

*Attention:None

*/

voidGPIO_Configuration(void)

{

GPIO_InitTypeDefGPIO_InitStructure;

/*TIM4_CH1pin(PB.06)configuration*/

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;

GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;

GPIO_Init(GPIOB,&GPIO_InitStructure);

/*TIM4_CH2pin(PB.07)configuration*/

GPIO_InitStructure.GPIO_Pin=GPIO_Pin_7;

GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;

GPIO_Init(GPIOB,&GPIO_InitStructure);

}

/*

*FunctionName:TIM4_Configuration

*Description:TIM4configuration:OnePulsemode

TheexternalsignalisconnectedtoTIM4_CH2pin(PB.07),

TheRisingedgeisusedasactiveedge,

TheOnePulsesignalisoutputonTIM4_CH1pin(PB.06)

TheTIM_Pulsedefinesthedelayvalue

The(TIM_Period-TIM_Pulse)definestheOnePulsevalue.

TIM2CLK=SystemCoreClock,wewanttogetTIM2counterclockat24MHz:

-Prescaler=(TIM2CLK/TIM2counterclock)-1

TheAutoreloadvalueis65535(TIM4->ARR),sothemaximumfrequencyvalue

totriggertheTIM4inputis24000000/65535=300Hz.

TheTIM_Pulsedefinesthedelayvalue,thedelayvalueisfixed

to682.6us:

delay=CCR1/TIM4counterclock=682.6us.

The(TIM_Period-TIM_Pulse)definestheOnePulsevalue,

thepulsevalueisfixedto2.048ms:

OnePulsevalue=(TIM_Period-TIM_Pulse)/TIM4counterclock=2.048ms.

*Input:None

*Output:None

*Return:None

*Attention:None

*/

voidTIM4_Configuration(void)

{

TIM_TimeBaseInitTypeDefTIM_TimeBaseStructure;

TIM_ICInitTypeDefTIM_ICInitStructure;

TIM_OCInitTypeDefTIM_OCInitStructure;

/*TIM4andGPIOBclockenable*/

RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4,ENABLE);

RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);

/*Computetheprescalervalue*/

PrescalerValue=(uint16_t)(72000000/10000)-1;

/* Time base configuration */

本站聲明: 本文章由作者或相關(guān)機(jī)構(gòu)授權(quán)發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點(diǎn),本站亦不保證或承諾內(nèi)容真實(shí)性等。需要轉(zhuǎn)載請(qǐng)聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權(quán)益,請(qǐng)及時(shí)聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。
換一批
延伸閱讀
關(guān)閉