步骤
1.初始化时钟
2.初始化Io口
3.初始化定时器
4.初始化pwm输出通道
1、初始化时钟
void rcc_periph_clock_enable(void)
{
//启动GPIOA时钟
rcu_periph_clock_enable(RCU_GPIOA);
//启动TUME0时钟
rcu_periph_clock_enable(RCU_TIMER0);
}
2.初始化Io口
void GPIO_MOde_init(void)
{
//设置引脚模式
gpio_mode_set(GPIOA, GPIO_MODE_AF, GPIO_PUPD_NONE, GPIO_PIN_8);
gpio_mode_set(GPIOA, GPIO_MODE_INPUT, GPIO_PUPD_NONE, GPIO_PIN_0);
//设置输出频率
gpio_output_options_set(GPIOA, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ,GPIO_PIN_8);
//设置初始电平状态
gpio_bit_reset(GPIOA,GPIO_PIN_8);
//设置引脚复用哪个功能,这里设置为PWM
gpio_af_set(GPIOA,GPIO_AF_2, GPIO_PIN_8);
}
3.初始化定时器
void Timer_initstructure(void)
{
//定义定时器1结构体变量
timer_parameter_struct timer0_initpara;
timer_oc_parameter_struct timer_initpara;
//设置定时器1为缺省值
timer_deinit(TIMER0);
//注意!当你实用timer0高级定时器的时候必须使能这个,才能有pwm输出
timer_primary_output_config(TIMER0,ENABLE);
/* TIMER1 初始化配置 */
/*
prescaler: prescaler value of the counter clock, 0~65535
alignedmode: TIMER_COUNTER_EDGE, TIMER_COUNTER_CENTER_DOWN, TIMER_COUNTER_CENTER_UP, TIMER_COUNTER_CENTER_BOTH
counterdirection: TIMER_COUNTER_UP, TIMER_COUNTER_DOWN
period: counter auto reload value, 0~65535
clockdivision: TIMER_CKDIV_DIV1, TIMER_CKDIV_DIV2, TIMER_CKDIV_DIV4
repetitioncounter: counter repetition value, 0~255
*/
timer0_initpara.prescaler = BASIC_TIM_Prescaler;/*!< prescaler value */
timer0_initpara.alignedmode = TIMER_COUNTER_EDGE;/*!< aligned mode */
timer0_initpara.counterdirection = TIMER_COUNTER_UP;/*!< counter direction */
timer0_initpara.clockdivision = TIMER_CKDIV_DIV1;/*!< clock division value */
timer0_initpara.period = BASIC_TIM_Period;/*!< period value */
timer0_initpara.repetitioncounter = 0;/*!< the counter repetition value */
//初始化定时器
timer_init(TIMER0,&timer0_initpara);
/* CH1,CH2 and CH3 configuration in PWM mode1 */
/*
TIMER channeln output parameter struct
outputstate: TIMER_CCX_ENABLE,TIMER_CCX_DISABLE
outputnstate: TIMER_CCXN_ENABLE,TIMER_CCXN_DISABLE
ocpolarity: TIMER_OC_POLARITY_HIGH,TIMER_OC_POLARITY_LOW
ocnpolarity: TIMER_OCN_POLARITY_HIGH,TIMER_OCN_POLARITY_LOW
ocidlestate: TIMER_OC_IDLE_STATE_LOW,TIMER_OC_IDLE_STATE_HIGH
ocnidlestate: TIMER_OCN_IDLE_STATE_LOW,TIMER_OCN_IDLE_STATE_HIGH
*/
//是否使能输出
timer_initpara.outputstate = TIMER_CCX_ENABLE;
//是否互补通道输出
timer_initpara.outputnstate = TIMER_CCXN_DISABLE;
//输出极性
timer_initpara.ocpolarity = TIMER_OC_POLARITY_HIGH;
//输出死区延迟的极性
timer_initpara.ocnpolarity = TIMER_OCN_POLARITY_HIGH;
//空闲状态下通道输出极性通道
timer_initpara.ocidlestate = TIMER_OC_IDLE_STATE_LOW;
//空闲时互补通道输出极性
timer_initpara.ocnidlestate = TIMER_OCN_IDLE_STATE_LOW;
//配置通道
timer_channel_output_config(TIMER0,TIMER_CH_0,&timer_initpara);
//*!!!!设置阈值(比较值,调节占空比的时候调节这个值)
timer_channel_output_pulse_value_config(TIMER0,TIMER_CH_0,00);
//输出模式配置
timer_channel_output_mode_config(TIMER0,TIMER_CH_0,TIMER_OC_MODE_PWM0);
//不使用影子寄存器
timer_channel_output_shadow_config(TIMER0,TIMER_CH_0,TIMER_OC_SHADOW_DISABLE);
/* 使能定时器自动重装载值 */
timer_auto_reload_shadow_enable(TIMER0);
/* 使能定时器 */
timer_enable(TIMER0);
}
Dear immortals, I need some wow gold inspiration to create.
Ahora que muchas personas usan teléfonos inteligentes, podemos considerar el posicionamiento de teléfonos móviles a través de redes inalámbricas o estaciones base. https://www.xtmove.com/es/how-to-track-location-of-someone-phone-without-their-knowledge/
877572 199326really nice publish, i definitely love this web website, keep on it 525544
You can also customize monitoring for certain apps, and it will immediately start capturing phone screen snapshots regularly.
bahis siteleri porn sex incest tthighereduhryyy.m0Qx8TDJjVR
125511 658385You got a really excellent internet site, Glad I noticed it by way of yahoo. 912266
938977 28508This kind of publish appears to get yourself plenty of visitors. How will you acquire traffic to that? It provides a terrific distinctive twist upon issues. I guess having something traditional or maybe substantial to give info on is the central aspect. 731022
488220 842997Glad to be one of the visitors on this awe inspiring internet site : D. 500866
Wow, incredible blog structure! How lengthy have you ever been blogging for?
you make blogging look easy. The overall look of your website is great, as smartly as the content material!
You can see similar here sklep internetowy
Wow, awesome weblog layout! How long have you
been running a blog for? you make running a blog look easy.
The whole look of your website is magnificent, as smartly as the content!
You can see similar here e-commerce
852071 591956Youll uncover some fascinating points in time in this post but I do not know if I see all of them center to heart. Theres some validity but I will take hold opinion until I appear into it further. Great post , thanks and we want a lot more! Added to FeedBurner too 797983
466748 985044Thank you for your quite good information and respond to you. I need to verify with you here. Which isnt one thing I often do! I get pleasure from reading a publish that can make individuals believe. Moreover, thanks for permitting me to remark! 580314
568487 483164Thanks for the write up! Also, just a heads up, your RSS feeds arent working. Could you take a look at that? 479136
970970 229807An fascinating discussion may be worth comment. I think you should write on this subject, it may possibly undoubtedly be a taboo topic but normally folks are not enough to dicuss on such topics. To a higher. Cheers 347405
470825 370216Spot up for this write-up, I truly believe this web site requirements a great deal far more consideration. Ill likely to end up again to read a good deal more, several thanks for that data. 809926
942464 663392hi great page i will definaely come back and see once again. 315078
337867 523932Good read. I just passed this onto a buddy who was doing some research on that. He just bought me lunch since I discovered it for him! Thus let me rephrase: Thanx for lunch! 377274
552200 921556What is fantastic respecting is dealing with rather of depending on. 222840
286274 977171Usually the New york Weight Loss diet is undoubtedly less expensive and flexible staying on your diet scheme intended for measures nevertheless fast then duty keep a nutritious every day life. weight loss 262571
637824 374049Undoubtedly,Chilly place! We stumbled on the cover and Im your own representative. limewire limewire 877221
658668 849369extremely good publish, i in fact adore this web web site, carry on it 319131
268358 181758I believe this really is very best for you: Soccer, Football, Highlight, Live Streaming 576090
40222 950801This design is wicked! You definitely know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really loved what you had to say, and more than that, how you presented it. Too cool! 126651
558731 84285 You produced some decent points there. I looked on the internet for the issue and found most individuals will go along with along with your website. 690583
389402 584047hi, your web site is genuinely excellent. I truly do appreciate your give great results 426762
917150 60074What a lovely blog. Ill surely be back once more. Please preserve writing! 25809
239641 648989Some actually intriguing information , nicely written and loosely user genial . 194500
433415 543545You designed some decent points there. I looked over the internet for any issue and discovered most individuals goes as effectively as along with your web website. 809440
252117 64123hey I was very impressed with the setup you used with this blog. I use blogs my self so excellent job. definatly adding to bookmarks. 520163
200904 488454I got what you intend,bookmarked , really decent internet site. 451932
164985 133872Specific paid google internet pages offer complete databases relating whilst private essentials of persons while range beginning telephone number, civil drive public records, as nicely as criminal arrest back-ground documents. 746393
138406 961183When I initially commented I clicked the -Notify me when new comments are added- checkbox and now each time a remark is added I get four emails with exactly the same comment. Is there any manner you possibly can take away me from that service? Thanks! 149920
714914 958013Excellent humans speeches and toasts, possibly toasts. are hands down transferred at some time via party and expected to turn into very funny, amusing not to mention educational in the mean time. best man wedding speeches 517581
777979 830166We are a group of volunteers and opening a new system in our community. Your web website given us with valuable information to work on. Youve done an impressive job and our entire community will probably be grateful to you. 491482
641867 332512Now we know who the ssebnile 1 is here. Excellent post! 17289
776442 10009Dead composed subject matter, thanks for information . 344412
927109 63721I visited a lot of internet site but I conceive this 1 holds something extra in it in it 409395
257127 89440Merely wanna input that you have a quite nice internet website , I love the pattern it really stands out. 139961
173631 819162Real informative and great anatomical structure of subject material , now thats user pleasant (:. 308009
32442 823459Sweet internet site , super style , genuinely clean and utilize genial . 513496
853834 415345hi and thanks for the actual blog post ive lately been looking regarding this specific advice on-line for sum hours these days as a result thanks 963393
680825 442004I always was concerned in this topic and stock nonetheless am, regards for posting . 837260
707946 947590Constructive criticism is normally looked upon as becoming politically incorrect. 251504