Generating PWM from PID to control DC motor

i read that most exmples are in analogwrite but i want to generate using digitalwrite because i want to change the time period of pwm