84798516PWM

所属分类:单片机开发
开发工具:C/C++
文件大小:236KB
下载次数:0
上传日期:2018-09-19 23:32:36
上 传 者5609062
说明:  单片机采用TIM1-PWM输出功能 output,支持4通道PWM输出设置
(Single chip microcomputer uses TIM1-PWM output function output to support 4 channel PWM output settings)

文件列表:
PWM\library\inc\stm8s_adc1.h (15301, 2008-09-25)
PWM\library\inc\stm8s_adc2.h (11058, 2008-09-25)
PWM\library\inc\stm8s_awu.h (4967, 2008-09-25)
PWM\library\inc\stm8s_beep.h (3569, 2008-09-25)
PWM\library\inc\stm8s_clk.h (17341, 2008-09-25)
PWM\library\inc\stm8s_exti.h (4568, 2008-09-25)
PWM\library\inc\stm8s_flash.h (10521, 2008-09-25)
PWM\library\inc\stm8s_gpio.h (6333, 2008-09-25)
PWM\library\inc\stm8s_i2c.h (15187, 2008-09-25)
PWM\library\inc\stm8s_itc.h (4272, 2008-09-25)
PWM\library\inc\stm8s_iwdg.h (4582, 2008-09-25)
PWM\library\inc\stm8s_lib.h (3259, 2008-09-25)
PWM\library\inc\stm8s_macro.h (6134, 2008-09-25)
PWM\library\inc\stm8s_map.h (79179, 2008-09-25)
PWM\library\inc\stm8s_rst.h (2813, 2008-09-25)
PWM\library\inc\stm8s_spi.h (12771, 2008-09-25)
PWM\library\inc\stm8s_tim1.h (24592, 2008-09-25)
PWM\library\inc\stm8s_tim2.h (13546, 2008-09-25)
PWM\library\inc\stm8s_tim3.h (12506, 2008-09-25)
PWM\library\inc\stm8s_tim4.h (5133, 2008-09-25)
PWM\library\inc\stm8s_type.h (3451, 2008-09-25)
PWM\library\inc\stm8s_uart1.h (15114, 2008-09-25)
PWM\library\inc\stm8s_uart2.h (17366, 2008-09-25)
PWM\library\inc\stm8s_uart3.h (13608, 2008-09-25)
PWM\library\inc\stm8s_wwdg.h (2390, 2008-09-25)
PWM\library\src\stm8s_adc1.c (26973, 2008-09-25)
PWM\library\src\stm8s_adc2.c (17083, 2008-09-25)
PWM\library\src\stm8s_awu.c (9436, 2008-09-25)
PWM\library\src\stm8s_beep.c (7199, 2008-09-25)
PWM\library\src\stm8s_clk.c (26492, 2008-09-26)
PWM\library\src\stm8s_exti.c (6926, 2008-09-25)
PWM\library\src\stm8s_flash.c (21474, 2008-09-25)
PWM\library\src\stm8s_gpio.c (10880, 2008-09-25)
PWM\library\src\stm8s_i2c.c (25947, 2008-09-25)
PWM\library\src\stm8s_itc.c (8907, 2008-09-25)
PWM\library\src\stm8s_iwdg.c (6140, 2008-09-25)
PWM\library\src\stm8s_rst.c (3427, 2008-09-25)
PWM\library\src\stm8s_spi.c (16784, 2008-09-25)
PWM\library\src\stm8s_tim1.c (103295, 2008-09-25)
PWM\library\src\stm8s_tim2.c (56866, 2008-09-25)
... ...

/** @page TIM1_7PWM_Output Generate 7 PWM signals with 4 different duty cycles @par Example description This example runs on STM8S-128K and STM8S-32K products. This example shows how to configure the TIM1 peripheral to generate 7 PWM signals with 4 different duty cycles. TIM1CLK is fixed to 2 MHz, the TIM1 Prescaler is equal to 0 so the TIM1 counter clock used is 2 MHz. (By default, fTimer1= fMaster/8 ) TIM1 frequency is defined as follows: TIM1 frequency = TIM1 counter clock / (TIM1_Period + 1) = 488.28 Hz. The TIM1 CCR1 register value is equal to 0x7FF, so the TIM1 Channel 1 and TIM1 Channel 1N generate a PWM signal with a frequency equal to 488.28Hz and a duty cycle equal to: TIM1 Channel1 duty cycle = TIM1_CCR1 /( TIM1_Period + 1) = 50%. The TIM1 CCR2 register value is equal to 0x5FF, so the TIM1 Channel 2 and TIM1 Channel 2N generate a PWM signal with a frequency equal to 488.28 Hz and a duty cycle equal to: TIM1 Channel2 duty cycle = TIM1_CCR2 / ( TIM1_Period + 1)= 37.5%. The TIM1 CCR3 register value is equal to 0x3FF, so the TIM1 Channel 3 and TIM1 Channel 3N generate a PWM signal with a frequency equal to 488.28 Hz and a duty cycle equal to: TIM1 Channel3 duty cycle = TIM1_CCR3 / ( TIM1_Period + 1) = 25%. The TIM1 CCR4 register value is equal to 0x1FF, so the TIM1 Channel 4 generate a PWM signal with a frequency equal to 488.28 Hz and a duty cycle equal to: TIM1 Channel4 duty cycle = TIM1_CCR4 / ( TIM1_Period + 1) = 12.5%. The TIM1 waveform can be displayed using an oscilloscope. @par Directory contents - main.c Main file containing the "main" function - stm8s_conf.h Library Configuration file - stm8s_it.c Interrupt routines source (not used in this example) - stm8s_it.h Interrupt routines declaration - stm8_interrupt_vector.c Interrupt vectors table @par Hardware environment Connect the TIM1 pins to an oscilloscope: - TIM1_CH1 pin (PC.1) - TIM1_CH1N pin (PH.7) - TIM1_CH2 pin (PC.2) - TIM1_CH2N pin (PH.6) - TIM1_CH3 pin (PC.3) - TIM1_CH3N pin (PH.5) - TIM1_CH4 pin (PC.4) @par How to use it ? In order to make the program work, you must do the following : - Create a project and setup all project configuration - Compile the directory content files and required Library files : + stm8s_tim1.c + stm8s_gpio.c - Rebuild all files: Project->Rebuild all. - Load project image: Debug->Start/Stop Debug Session - Run program: Debug->Run (F5) - Connect the TIM1 pins to an oscilloscope Go to main file: TIM1_7PWM_Output\main.c */ /******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

近期下载者

相关文件


收藏者