The BSS123 has a max vgs of 20V. I'm driving the gate at 24V with a PWM wave at 22khz 50% duty cycle.
Circuit works as intended but is the gate seeing the average of the PWM? Or is the absolute max rating of 20V vgs on the fet a peak regardless of pulse width?
The reason for the 20V limit is due to the thickness of the gate oxide on the MOSFET transistor ... as a general rule, the dielectric strength of the oxide is slightly more than 3V per micron and the typical oxide thickness is about 6 microns. Exceeding the rated voltage will cause a spark to penetrate the oxide layer and once that happens the transistor becomes damaged, most often inoperable.
It sees the average only if you have an RC low-pass filter averaging the PWM signal to get DC at the gate.
Otherwise the peak voltage may damage the gate oxide.
But, if you do add an RC network to the PWM gate, your motor speed will not be a linear response to duty cycle and the motor will stop sooner as duty cycle is decreased.
You are much better off adding a voltage divider with two resistors or, better, use a 10v zener diode and a current limiting resistor.