Searching \ for 'PWM Code Help Please For PIC16C73A' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=pwm
Search entire site for: 'PWM Code Help Please For PIC16C73A'.

Truncated match.
PICList Thread
'PWM Code Help Please For PIC16C73A'
1999\01\20@192236 by Timothy Deterly

flavicon
face
part 0 1343 bytes
Thanks a lot,
Timothy Deterly
spam_OUTtimdetTakeThisOuTspamsan.rr.com

P.S. I am sorry if the included file is to big to post to the list, I
thought it would be ok.
;10 MHz crystal, 4 kHz PWM, Duty by portB
       LIST p=16c73a, r=hex
#include "P16c73a.inc"

Start
       BCF     STATUS, RP0     ; Bank 0
       CLRF    TMR1H
       CLRF    TMR1L

       CLRF    STATUS
       CLRF    INTCON
       CLRF    PIR1

       BSF     STATUS, RP0     ; Bank 1
       MOVLW   0x80
       MOVWF   OPTION_REG

       MOVLW   b'10011011'     ; 155  Period to make 4.006 khz
       MOVWF   PR2

       BCF     STATUS, RP0     ; Select Bank 0
       CLRF    PORTC
       CLRF    PORTB
       CLRF    CCPR1L


       BSF     STATUS, RP0     ; Select Bank 1
       CLRF    TRISC           ; RC Port are outputs
       movlw   0xff
       movwf   TRISB           ; PORTB Inputs

       BCF     STATUS, RP0     ; Select Bank 0
       CLRF    T2CON
       BSF     T2CON,0
       BSF     T2CON,TMR2ON    ; Turn Timer 2 ON

       MOVLW   0X0C            ; CCP module is in
       MOVWF   CCP1CON         ; PWM output mode
       BCF     CCP1CON,5       ; Hard coded doesn't matter.
       BSF     CCP1CON,4

loop    movf    PORTB,w         ; Change duty to PORTB
       movwf   CCPR1L
       Goto    loop            ; Loop forever.
       END

1999\01\20@193309 by mwestfal

flavicon
face
Timothy Deterly wrote:

> Hey Everyone,
>         I am just starting to learn to use the PIC16C73A and have been trying
> to get the CCP module to output PWM.  I have written some code for it
> that seems to work most of the time but not always, the PIC sometimes
> seems to hang (stop running). And also the duty cycle doesn't seem to be
> right, i.e. when it should be at 50% it is 65% or sometimes more!  So I
> was wondering if anyone would mind looking a it for me?



In order to get 50% duty cycle, CCPR1L has to be half the value you put in PR2.

-------------------------------------------------------------------------------
Mike
.....mwestfalKILLspamspam@spam@odc.net
http://web.csusb.edu/public/csci/mwestfal
Linux religious dogma: "The Gates of Hell shall not prevail."
-------------------------------------------------------------------------------

1999\01\21@115118 by andre

flavicon
face
Hey Timothy,

I am currently working on 16c73a pwm and uart for serial lcd
and keypad. I am not sure if you know about this or not that
PR2 register is not for frequency only when you change the
value in PR2 it also effects duty cycle range. example

PR2 = 155 this means   on CCPR2L if  you load 155 it will be 100%
duty cycle over 155 still will be 100%.
if you change pre scaler in timer2    1/4/16 it will change the frequency
without effecting duty cycle range.
you really need to work with formula. now to answer your
main question that some times works or not  there are 2 possibilities
I am  sure it should be one of them.

1. you didn't initialize all ram locations
2. you have  page boundary problem.

Timothy Deterly wrote:

> Hey Everyone,
>         I am just starting to learn to use the PIC16C73A and have been trying
> to get the CCP module to output PWM.  I have written some code for it
> that seems to work most of the time but not always, the PIC sometimes
> seems to hang (stop running). And also the duty cycle doesn't seem to be
> right, i.e. when it should be at 50% it is 65% or sometimes more!  So I
> was wondering if anyone would mind looking a it for me?
>

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...