CTC mode PWM generation only when i have pulde on my Input on Attiny13

Hi everyone I am on a project on attiny13. I want to drive my MOSFET with alternative switching at 100 Khz only when I have a square pulse input in the frequemcy range 3khz to 5 khz. Now i am in the position I have two seperate program. First that detect the pulse width and measure the frequency and make one pin high when i have in 3 to 5khz frequency range otherwise not. second i have program that drive MOSFET alternatively with 100khz frequency. Both program working fine seperately. When i combine these two program the input side is working. That means i will get my pulse output only when i have frequency betwwen 3 ti 5 khz but the pulse now that need to be given to MOSFET is not alternative. they are same and the pulse width is also not uniform. Can any body help me