Hi,
> MCGC2 = MCGC2 & 0b11111111;
>
> does not compile (int to unsigned char conversion error).
Arithmetic operators produce integer results by default, and an implicit cast from an integer to an unsigned char produces a warning/error by default.
You might try an unsigned char operator:
MCGC2 &= 0b11111111;
Or an explicit cast:
MCGC2 = (unsigned char)(MCGC2 & 0b11111111);
Or just disable the error/warning:
turn off "Implicit Arithmetic Conversions" in project settings -> C/C++ Warnings
I actually run with that error/warning disabled.
-- Rich