Searching \ for '[PIC]: F874 PWM WHY WONT THIS WORK?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/microchip/ios.htm?key=pwm
Search entire site for: 'F874 PWM WHY WONT THIS WORK?'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: F874 PWM WHY WONT THIS WORK?'
2000\09\10@234330 by robsymmans

flavicon
face
HI All, I am having problems with the following snippet - it sets up the
PWM1 output ok
but I get nothing from the second pwm output. I have even resorted to a chip
swap to check the controller. Adding a BSF to assert the pin works, but the
pwm does not.
any advice gratefully received
thanks
rob symmans



       CALL    INIT_PORTS

       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 PERIOD
       MOVWF   CCPR2L          ; DUTY CYCLE IS ~50% OF PWM 2 PERIOD
       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

HERE    GOTO    HERE

INIT_PORTS
       MOVLW   B'00000000'
       MOVWF   TRISC
       RETURN

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

2000\09\11@030700 by Ray Gardiner

flavicon
face
I use dual PWM on the 16F874,16C77 and 16C74 basically the initialization is
pretty similar to what you have below, except the following comments

My initialization is as follows,

       CCP1CON = 0x00;
       CCP2CON = 0x00;
       CCP1CON = 0b00001100;
       CCP2CON = 0b00001100;
       T1CON   = 0b00000101;
       T2CON   = 0b01111110;  // timer 2 pre/post scaler
       PR2     = 0xff;        // slowest possible pwm freq..
       TMR2    = 0x00;

Actually driving the pwm outputs is done as follows.

void SetPWM2 ( unsigned int w)
{
       CCP2Y = w & 0x01;
       CCP2X = w & 0x02;
       CCP2RL= w>>2;
}

void SetPWM1 ( unsigned int w)
{
       CCP1Y = w & 0x01;
       CCP1X = w & 0x02;
       CCP1RL= w>>2;
}


Hope this helps.


{Quote hidden}

Ray Gardiner spam_OUTrayTakeThisOuTspamdsp.com.au
mail from: dsp systems

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

2000\09\11@183244 by Tony Nixon

flavicon
picon face
robsymmans wrote:
>
> HI All, I am having problems with the following snippet - it sets up the
> PWM1 output ok
> but I get nothing from the second pwm output. I have even resorted to a chip
> swap to check the controller. Adding a BSF to assert the pin works, but the
> pwm does not.
> any advice gratefully received
> thanks
> rob symmans

Hi Rob,

I uploaded your code to ROMzap and ran it and it worked ok.

I got a square wave from RC1 and RC2 using a 16F873.


Bare in mind that with your code, all PORTA, PORTB and perhaps D and E
are floating digital and analog inputs. This can cause problems.

--
Best regards

Tony

ICmicro's
http://www.picnpoke.com
.....salesKILLspamspam@spam@picnpoke.com

--
http://www.piclist.com hint: The PICList is archived three different
ways.  See http://www.piclist.com/#archives for details.

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