Can some please explain where I am going wrong as I want to be able to vary the pwm level fed to the mosfet driver over the fixed time period?
So you want to be able to vary the PWM during the WAIT then turn off ?
You cannot do it during the WAIT as such but you can slice the WAIT up into smaller pieces and execute a number of those to effectively create a longer WAIT, and while executing those smaller WAIT's you can add the code to read the ADC and set the PWM.
The first step is to take what you currently have working, adjust that to have the WAIT period you want but using a loop which includes shorter WAIT's. Then insert the READADC and setting PWMOUT from variable code.
Or alternatively - and simpler once you've done it - you can use the multi-tasking capabilities of the 18M2 to do what you want. One task will wait until activated, start a second task, WAIT however long, then stop the second task, stop the PWMOUT. The second task will simply READADC and set PWMOUT.