Hi David,
Your observation peek my interest to run a test on our KDS2.0.0/demo/rtc_demo project. Sorry this is not using PE and MQXLite but it might provide direction for you to enable it and also provide others that would want this baremetal capability to test with on the FRDM-K22F120M.
If you do implement with PE+MQXLite please post it back here. If you don't get to it, I'll try when I have additional time.
My FRDM-K22F120M didn't have battery so I wire wrapped one on and cut track under (backside) J21 jumper.
This allows VBAT to operate the RTC if the USB debugger is not connected.
My code doesn't use ADC to check if there is VBAT. It assumes VBAT is valid/present.
When you run code for the first time, the RTC is not enabled. Code will do that and give it an initial date/time.
Use the terminal interface to set the correct date/time.
Once this is complete you can disconnect the USB debugger cable from FRDM-K22F120M and date/time will be maintained.
Be sure to have disconnected or exited your VCOM terminal interface before re-connecting the USB debugger cable to allow VCOM enumeration.
Once USB debugger cable re-connect some time later, re-connect your terminal window and hit Enter to see terminal options and also at top it will display the current date/time.
My example Terminal output:
Serial port COM15 opened
1
Current datetime: 2014-04-30 14:00:03
Please choose the sub demo to run:
1) Get current date time.
2) Set current date time.
NOTE: Accuracy maybe affected by a few seconds if RTC counter clock is not 32KHz.
3) Alarm trigger show.
NOTE: Alarm will be delayed if RTC counter clock is not 32KHz.
4) Second interrupt show (demo for 20s).
NOTE: Interrupt will be delayed if RTC counter clock is not 32KHz.
5) Set RTC compensation.
Select:2
Input date time like: "2014-04-22 16:40:00"
2015-02-18 14:47:00
Current datetime: 2015-02-18 14:47:00
Please choose the sub demo to run:
1) Get current date time.
2) Set current date time.
NOTE: Accuracy maybe affected by a few seconds if RTC counter clock is not 32KHz.
3) Alarm trigger show.
NOTE: Alarm will be delayed if RTC counter clock is not 32KHz.
4) Second interrupt show (demo for 20s).
NOTE: Interrupt will be delayed if RTC counter clock is not 32KHz.
5) Set RTC compensation.
Select:1
Current datetime: 2015-02-18 14:47:01
Please choose the sub demo to run:
1) Get current date time.
2) Set current date time.
NOTE: Accuracy maybe affected by a few seconds if RTC counter clock is not 32KHz.
3) Alarm trigger show.
NOTE: Alarm will be delayed if RTC counter clock is not 32KHz.
4) Second interrupt show (demo for 20s).
NOTE: Interrupt will be delayed if RTC counter clock is not 32KHz.
5) Set RTC compensation.
Select:
Serial port COM15 closed
Serial port COM15 opened
1
Current datetime: 2015-02-18 14:48:11
Please choose the sub demo to run:
1) Get current date time.
2) Set current date time.
NOTE: Accuracy maybe affected by a few seconds if RTC counter clock is not 32KHz.
3) Alarm trigger show.
NOTE: Alarm will be delayed if RTC counter clock is not 32KHz.
4) Second interrupt show (demo for 20s).
NOTE: Interrupt will be delayed if RTC counter clock is not 32KHz.
5) Set RTC compensation.
Select:
Regards,
David