Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.
Here you will find an example of a code for 8051 on PWM controlled LEDs: https://www.iguanalabs.com/pwm.htm
There will be scores of other examples but I think this one is one of the simples and most comprehensive desription of PWM using basic 8051 (without built-in PWM block) ..
As you probably know, some of 8051 microcontrollers have a PWM module built in. In this case control of this module is relatively simple.
If you would like to compare more examples on PWM and 8051, do you prefer pure 8051-core (software PWM) or 8051 derivatives with buil-in PWM module (hardware solution) ?