Thanks Andrew, I have solved the problem in the same time when I have asked the question You know what a good teacher said: "I have explained the problem to my students once, then twice and they don't understood, third time almost I have understood the problem but they still don't understood...What should I do with them ?" I have do it almost in the same fashion like you say here... but I was using 6 fixed time point comparations with the flowing seconds. Thanks for the tip. Vasile On Tue, 2 Apr 2002, Andrew Warren wrote: > Vasile Surducan 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 - aiw@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 > > -- 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