| Zakładka z wyszukiwarką danych komponentów |
|
AN590 Arkusz danych(PDF) 4 Page - STMicroelectronics |
|
|
|||||||||||||||||||||||||||||
AN590 Arkusz danych(HTML) 4 Page - STMicroelectronics |
|
4 / 7 page ![]() 4/7 PWM GENERATION WITH ST62 AUTO-RELOAD TIMER Program example: – SC0 is not programmed, so it keeps its reset value 00h (all flags cleared) – The PWM signal starts as soon as the last instruction (ldi MC) is executed Program example ****************** A-R Timer Register Set ******************************** RC .def 0D9h,0FFh,0FFh ;reload/capture register CP .def 0DAh,0FFh,0FFh ;compare register MC .def 0D5h,0FFh,0FFh ;mode control register SC0 .def 0D6h,0FFh,0FFh ;status/control register 0 SC1 .def 0D7h,0FFh,0FFh ;status/control register 1 LR . def 0DBh,0FFh,0FFh ;load register ;============================================================ ldi CP, 186 ;compare register = 186d ldi RC, 145 ;reload register = 145d ldi SC1,001h ;clock source= CPU clock divided by 3 ;prescaler ratio = 1 ldi MC, 11100000b ;auto-reload mode,interrupts disabled ;PWMOUT enabled, start timer Example 2: Target: generate a PWM signal of frequency 31.25 kHz with a duty cycle proportional to an input analog voltage varying between 0V and VCC: 0V corresponds to 0% duty cycle, VCC cor- responds to 100% duty cycle. The CPU clock is 8 MHz: Referring to example 1, we find that the prescaler ratio must be 1, the value in RC must be 0 and the value in CP is taken directly from the A/D output (varying from 0 to 255d depending upon the analog input): RC = 0 CP = 0...255d prescaler ratio = 1 FIN = 8 MHz FPWM = 8 MHz / 256 = 31.25 kHz Duty cycle = CP / 256d Resolution = 1/256d = 0.39 % We need to implement a software loop which repetitively converts the analog input to a digital value and copies this digital value into CP: |
|
|
Link URL |
| Czy Alldatasheet okazała się pomocna? [ DONATE ] |
O Alldatasheet | Reklama | Kontakt | Polityka prywatności | Link do karty katalogowej | Linki | Lista producentów All Rights Reserved©Alldatasheet.com |
| 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 |