piclist 2000\05\19\113614a >
Thread: Simple 16C73 PWM routine?
face BY : Matt Sidare email (remove spam text)


Here's a short bit of code that sets up the PWM and sets the PWM to ~50%
duty cycle
I copied it from some code that works,  Its been a while since I wrote it
I may have forgot to copy something.  Try it and let us know.

       MOVLW   0xFF                    ; 00 --> W
       BSF             STATUS, RP0             ; Select bank 1
       MOVWF   PR2                     ; Load PR2 with period info
                                               ; at 20MHz PR2=FF gives a 1.22KHz
                                               ; at 4MHz PR2=FF gives a 3.906KHz
       BCF             STATUS, RP0             ; Select bank 0
       MOVLW   0X80                    ; Load W with 0X80
       MOVWF   CCPR1L          ; Duty Cycle is ~50% of PWM 1 Peroid
       MOVWF   CCPR2L          ; Duty Cycle is ~50% of PWM 2 Peroid
       BSF             T2CON, T2CKPS1  ; Set the TMR2 prescale value
       BSF             T2CON, T2CKPS0  ; Set the TMR2 prescale value
       BSF             T2CON, TMR2ON   ; Enable timer2
       MOVLW   0X0F                    ;
       MOVWF   CCP1CON         ; SET low two bits of PWM 1 and turn it on
       MOVWF   CCP2CON         ; SET low two bits of PWM 2 and turn it on
                                               ; PWM has 10-bits of resolution


<001001bfc1a7$70fa3c10$6b0210ac@msmetpc.tropel.com> 7bit

In reply to: <6621F2E12035D311B02208002BC33C593B1C5C@landuk1.landinst.com>
See also: www.piclist.com/techref/microchip/ios.htm?key=pwm
Reply You must be a member of the piclist mailing list (not only a www.piclist.com member) to post to the piclist. This form requires JavaScript and a browser/email client that can handle form mailto: posts.
Subject (change) Simple 16C73 PWM routine?

month overview.

new search...