Searching \ for 'PWM lowest frequency...' in subject line. ()
Help us get a faster server
FAQ page: www.piclist.com/techref/io/pwm/index.htm?key=pwm
Search entire site for: 'PWM lowest frequency...'.

Truncated match.
'PWM lowest frequency...'
2000\05\11@171041 by

Am I missing something?  If I'm running on a 4MHz PIC, the lowest frequency
PWM that I can generate would be:

PWM period = (255 + 1) * 4 / 4,000,000 * 16 = 0.004096

...giving a frequency of:  244.14 Hz

What do I do if I need a lower frequency than this?

Thanks!!

Jeffrey Siegel wrote:
> Am I missing something?  If I'm running on a 4MHz PIC, the lowest frequency
> PWM that I can generate would be:
>
> PWM period = (255 + 1) * 4 / 4,000,000 * 16 = 0.004096
>
> ...giving a frequency of:  244.14 Hz
>
> What do I do if I need a lower frequency than this?
>
> Thanks!!

What would stop you from implementing a software loop to make a, say, 1
year period if you needed that?  (Software bit-banged PWM...)

Mark

Hello..

I' resolve the problem in hardware with the module CCP1 in mode comparation
( CCP1CON = 00001010 ), the TIMER1 with prescaler /8 and crystal extern of
40Khz between the pins RC0/T1OSO/T1CKI and RC1/T10SI/CCP2.
The TIMER1 in loop free, increment each 200useg (without interrupt in
overflow).

40000Hz / 8 = 5000Hz
1 / 5000Hz  =  200useg

resolution pwm = 200useg.

as I' like pwm at 50Hz

1 / 50Hz = 20000useg

with a scale of 100 step

100 * 200useg = 20000useg

The code to generate the cycle active and inactive
of pwm into of ISR:

a - input ISR
b - stop TIMER1 ( bcf T1CON,TMR1ON )
c - ( TMR1H-TMR1L + cycle active required ) --> CCPR1H-CCPR1L
d - set or clear pin used to pwm
e - enable comparator CCP1
f -  enable TIMER1 ( bsf T1CON,TMR1ON )
g -  restore FSR-STATUS-W
h -  exit ISR

Pwm0
bsf          RFlags,_Pwm         ;The next is the active cycle
bcf          T1CON,TMR1ON     ;Disable the TMR1
movf       TMR1H,W               ;Copy the part high of TMR1
movwf    CCPR1H                  ;in the part high of CCP1
movf       TMR1L,W                ;TMR1L --> W to add
addwf     RInactiveCycle,W      ;(TMR1L + RInactiveCycle) --> W
skpnc                                   ;? Carry ?
incf        CCPR1H,F               ;Yes CCPR1H + 1 --> F
movwf    CCPR1L                   ;Load the part low of comparator
movlw    B'00001010'              ;Configuration of CCP1 to
movwf   CCP1CON                 ;generate interrupt
bsf         STATUS,RP0           ;Bank 1
bsf        PIE1,CCP1IE            ;Enable the interrupt of comparator 1
bcf        STATUS,RP0            ;Bank 0
bsf        T1CON,TMR1ON       ;Enable the TMR1
bcf        HAB                         ;begin the inactive cycle
goto      RestoreRegisters       ;Restore FSR-STATUS-W

Pwm1
bsf          RFlags,_Pwm         ;The next is the inactive cycle
bcf          T1CON,TMR1ON     ;Disable the TMR1
movf       TMR1H,W               ;Copy the part high of TMR1
movwf    CCPR1H                  ;in the part high of CCP1
movf       TMR1L,W                ;TMR1L --> W to add
addwf     RActiveCycle,W       ;(TMR1L + RActiveCycle) --> W
skpnc                                   ;? Carry ?
incf        CCPR1H,F               ;Yes CCPR1H + 1 --> F
movwf    CCPR1L                   ;Load the part low of comparator
movlw    B'00001010'              ;Configuration of CCP1 to
movwf   CCP1CON                 ;generate interrupt
bsf         STATUS,RP0           ;Bank 1
bsf        PIE1,CCP1IE            ;Enable the interrupt of comparator 1
bcf        STATUS,RP0            ;Bank 0
bsf        T1CON,TMR1ON       ;Enable the TMR1
bsf        HAB                         ;begin the active cycle
goto      RestoreRegisters       ;Restore FSR-STATUS-W

Regards...

Nestor Ariel Marchesini
repetidora radio club Chajari LU5JC 145405 -600
Chajari-Entre Rios-Argentina
ICQ # 50983752 nick colo
nestormbiybyte.com.ar

----- Original Message -----
From: Jeffrey Siegel <jeffrey.siegelACTIVECENTER.COM>
Sent: Thursday, May 11, 2000 6:00 PM
Subject: PWM lowest frequency...

| Am I missing something?  If I'm running on a 4MHz PIC, the lowest
frequency
| PWM that I can generate would be:
|
| PWM period = (255 + 1) * 4 / 4,000,000 * 16 = 0.004096
|
| ...giving a frequency of:  244.14 Hz
|
| What do I do if I need a lower frequency than this?
|
| Thanks!!
|

From: "Nestor A. Marchesini" <nestormBITBYTE.COM.AR>
>
> I' resolve the problem in hardware with the module CCP1 in mode
comparation
> ( CCP1CON = 00001010 ), the TIMER1 with prescaler /8 and crystal extern of
> 40Khz between the pins RC0/T1OSO/T1CKI and RC1/T10SI/CCP2.
> The TIMER1 in loop free, increment each 200useg (without interrupt in
> overflow).
>

Thanks Nestor - I didn't realize it could be done that way.  It uses some
extra hardware that I need for other uses though.

From: "Mark Willis" <mwillisFOXINTERNET.NET>
> What would stop you from implementing a software loop to make a, say, 1
> year period if you needed that?  (Software bit-banged PWM...)

Yep...thats what I did.  It works fine but it would have been a lot more
elegant to be able to set it and forget it (sounds like an infomercial...).
I'm putting different frequencies on the PWM at various times, so I have a
switch for whether it is PWM generated or bit-bang generated.  It's just
more messy that way...

Thanks again for all of your responses...

...Jeff

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