Hello,
I assume that you are attempting to clear the flags using -
TODSC_SECF = 1;
TODSC_MTCHF = 1;
Unfortunately, with more than one flag within the register, this code will have the effect of clearing all flags, as you have observed. The reason lies with the compiler using a read-modify-write process within the generated code, i.e BSET command. Any of the bits, other than the specified bit, will also read as a 1, if set. The bits will then be written back to the register as 1s, which will clear all the flag bits.
The solution is to use a write only process -
#define TODSCval 0x0E;
TODSC = TODSCval | TODSC_SECF_MASK;
TODSC = TODSCval | TODSC_MTCHF_MASK;
If the TOD counter is to be used as a wakeup source, it would need to be running whilst the MCU is in stop mode.
Regards,
Mac