数据搜索系统,热门电子元器件搜索
  Chinese  ▼
ALLDATASHEETCN.COM

X  

AN1504 数据表(PDF) 4 Page - STMicroelectronics

部件名 AN1504
功能描述  STARTING A PWM SIGNAL DIRECTLY AT HIGH LEVEL USING THE ST7 16-BIT TIMER
PDF  9 Pages
Scroll/Zoom Zoom In 100%  Zoom Out
制造商  STMICROELECTRONICS [STMicroelectronics]
网页  http://www.st.com
标志 STMICROELECTRONICS - STMicroelectronics

AN1504 数据表(HTML) 4 Page - STMicroelectronics

  AN1504 Datasheet HTML 1Page - STMicroelectronics AN1504 Datasheet HTML 2Page - STMicroelectronics AN1504 Datasheet HTML 3Page - STMicroelectronics AN1504 Datasheet HTML 4Page - STMicroelectronics AN1504 Datasheet HTML 5Page - STMicroelectronics AN1504 Datasheet HTML 6Page - STMicroelectronics AN1504 Datasheet HTML 7Page - STMicroelectronics AN1504 Datasheet HTML 8Page - STMicroelectronics AN1504 Datasheet HTML 9Page - STMicroelectronics  
Zoom Inzoom in Zoom Outzoom out
 4 / 9 page
background image
4/9
STARTING A PWM SIGNAL DIRECTLY AT HIGH LEVEL USING THE ST7 16-BIT TIMER
2 FIRST CASE: OLVL2=1 AND OLVL1=0
In this case, to force a high state on the OCMP1 pin when the timer is started:
– Initialize the timer in PWM mode and set the PWM frequency with a 0% duty cycle
– Reset the timer (at FFFC)
– Load the OC1R register with a value close to FFFC (FFFD for example) and configure
OLVL1=1 and OLVL2=0.
– Start the timer. It immediately reaches the value of the OC1R register and OCMP1 pin goes
into the state defined by the OLVL1 bit, which is high.
– Then, write the correct duty cycle value in the OC1R register and the correct state in the
OLVL2 and OLVL1 bits (OLVL2=1 and OLVL1=0).
The following code gives an example of how to restart (or start) the 16-bit timer this way. This
is for Timer A already initialized in PWM mode at 10KHz with the 16-bit timer clocked at 1MHz
(TACR2=10011000, TAOC2HR=$00 and TAOC2LR=$5F for 10KHz at 1MHz clock.
This is how to calculate the values to be put in the registers:
– OC2R represents the signal period. The frequency is 10KHz, so the period is t=100µs. fCPU
is 8MHz and the Timer prescaler is 8 because the Timer is at 1MHz.
OC2R=((t*Fcpu)/presc)-5=((100.10-6*8.10+6)/8)-5=95 (005F in hexadecimal).
– OC1R represents the pulse length, the duty cycle is 50% so the pulse length is
100µs*50%=50µs. So the value to be put in OC1R is:
OC1R=((50.10-6*8.10+6)/8)-5=45 (002D in hexadecimal).
Note: This method can be applied when the counter is first started as the starting value is
0000.
Initialization: In this example the duty cycle is first set to 0% with OLVL1=0 and OLVL2=0
ld A,#%00000000; set OLVL1=0 and OLVL2=0
ld TACR1,A
ld A,#%10011000; clock in/8=1MHz with 16 MHz quartz
ld TACR2,A
ld A,#$00
ld TAOC2HR,A
;10KHz frequency for the PWM signal (see formulas)
ld A,#$5F
ld TAOC2LR,A
Synchronization
ld A,#%00000001;Set OLVL1=1 and OLVL2=0
ld TACR1,A
;load corresponding control register 1
ld A,#$FF
ld TAOC1HR,A
;fix compare 1 to FFFD to force PWM high as soon as possible
ld A,#$FD



Html Pages

1 2 3 4 5 6 7 8 9


数据表 下载

Go To PDF Page


链接网址



ALLDATASHEET是否为您带来帮助?  [ DONATE ] 

关于 Alldatasheet   |   广告服务   |   联系我们   |   隐私政策   |   数据表链接    |   链接交换   |   制造商名单
All Rights Reserved©Alldatasheet.com


Mirror Sites
English : Alldatasheet.com  |   English : Alldatasheet.net  |   Chinese : Alldatasheetcn.com  |   German : Alldatasheetde.com  |   Japanese : Alldatasheet.jp
Russian : Alldatasheetru.com  |   Korean : Alldatasheet.co.kr  |   Spanish : Alldatasheet.es  |   French : Alldatasheet.fr  |   Italian : Alldatasheetit.com
Portuguese : Alldatasheetpt.com  |   Polish : Alldatasheet.pl  |   Vietnamese : Alldatasheet.vn
Indian : Alldatasheet.in  |   Mexican : Alldatasheet.com.mx  |   British : Alldatasheet.co.uk  |   New Zealand : Alldatasheet.co.nz
Family Site : ic2ic.com  |   icmetro.com