Hi there,
Last year I have written the routine for PWM generation.
I am copying that code here for you
Code:
for_rise_on1 clr mot1for ;on period of pwm
mov r2,30H
djnz r2,$
setb mot1for ;off period of pwm
mov r2,31H
djnz r2,$
djnz r3,for_rise_on1 ;repeat the loop 10 times
mov r3,#10
mov a,30H
add a,# 5 ;increment on period by 10 microsec
mov 30H,a
mov a,31H
subb a,# 5 ;decrement off period by 10 microsec
mov 31H,a
djnz r4,for_rise_on1 ;repeat the loop 20 times
mov r4,#20
clr mot1for