Shifting between PWM options
You're setting TPM1C2SC to one value on every iteration of the outer loop, and setting it to a different value for only part of one iteration out of every 65536.

You need a state variable to keep track of whether you're currently fading up or down, and only update TPM1C2SC to the next value on every 65536th iteration. Don't forget to initialize it before entering the loop, too.