ISR:
1. Check if timer interrupt occurs
2. Preload timer with x
3. Do required job like setting the pin or clearing it
4. Clear flag (if required, I don't know about 8051, but it's not required in AVR but required in PIC)
5. Return from ISR
end ISR
main code:
* Initialize everything required, ie the ports, port directions, timer, etc
1. Enable timer interrupt
2. Enable global interrupt (if there is such a thing)
3. Determine required value for duty cycle as : x(the preload value) = required duty cycle(0 to 1) * 255
4. Load x into the timer
5. Do other jobs while interrupt happens
end main code