Generator ON/OFF

It appears you or someone has gone to great lengths to automatically generate a sine wave.

You are going to have to go to equal lengths to make it start and stop at the rate of your LED there.

Look at the matlib code.

Just writing to that pin is very likely being nearly instantaneously changed by the process running on interrupts. At best, you might see little glitches, probably not.

a7