> Vasile Surducan <
KILLspamPICLISTKILLspam
mitvma.mit.edu> wrote:
>
> > I need a finest resolution so every time the minimum period will be 10
> > seconds and no more, for 10 minutes and 10% I need to do 60 times 1
> > second on and 9 secons off.
>
> Ah, ok... NOW I understand. I, too, was puzzled when I saw that
> question coming from you.
>
> Something like this should work; it is -- as so many things are --
> a
> variation on the Bresenham line-drawing algorithm:
>
> ; Enter with duty-cycle (0-100) in DUTY. This routine uses a
> ; register called SWITCH which must not change between calls
> ; to the routine. Note that I'm assuming RADIX=DEC.
>
> TIMER_INTERRUPT:
>
> TSTF DUTY
> BNZ TESTSW
>
> MOVLW -1
> MOVWF SWITCH
>
> TESTSW:
>
> BTFSS SWITCH,7
> GOTO TURNON
>
> BCF OUTPUT_PIN
> GOTO FINISH
>
> TURNON:
>
> BSF OUTPUT_PIN
>
> MOVLW 100
> SUBWF SWITCH
>
> FINISH:
>
> MOVF DUTY,W
> ADDWF SWITCH
>
> This will ALWAYS produce the minimum PWM period necessary for a
> particular duty-cycle. In other words, DUTY=50 will result in
>
> ON-OFF
> ON-OFF
> etc.
>
> and DUTY=10 will result in
>
> ON-OFF-OFF-OFF-OFF-OFF-OFF-OFF-OFF-OFF
> ON-OFF-OFF-OFF-OFF-OFF-OFF-OFF-OFF-OFF
> etc.
>
> -Andy
>
> === Andrew Warren -
RemoveMEaiwTakeThisOuT
cypress.com
> ===
> === Principal Design Engineer
> === Cypress Semiconductor Corporation
>
> --
>
http://www.piclist.com hint: PICList Posts must start with ONE topic:
> [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads
>
>