I've been trying unsuccessfully to get the 1Hz RTC clock to appear on PTB13, the RTC_CLKOUT pin.
Here is what I am doing to set-up the RTC and clocks to enable this to happen:
// (01)Set the clock ERCLK32K output on pin13, (00) clock not output
// Enable access and interrupts for RTC
// Enable a clock for the RTC so it can output the 1Hz clock, OSC32KCLK (00), LPO(11), RTC_CLKIN (10)
//Selects the RTC 1Hz (0) or OSCERCLK (1) Clock for output on RTC_CLKOUT pin
//Enable the time counter
//Enable the port
PORT_BWR_PCR_MUX(PORTB, 13, 0b011); //Set the Alt3 muxing on PortB, pin 13 for RTC_CLKOUT
GPIO_SET_PDDR(GPIOB, 1U<<13); //Set PORTB pin 13 to output
This does not work, I get a flat line on PTB13. I have played with the sequence of some of these commands, like enabling the time counter RTC_SR after the port definition, but no change. If I change the RTCCLKOUTSEL to 1, I do see the correct signal on PTB13. I am puzzled! Is there something I'm missing?
Also, what is the meaning of "Pad Interface" in Figure 5-4 from the user's manual?
As long as you have the RTC operating the only thing needed to output RTC_CLKOUT (1Hz) is to select ALT3 use of PTB13.
I do it like this:
_CONFIG_PERIPHERAL(B, 13, (PB_13_RTC_CLKOUT | PORT_SRE_SLOW | PORT_DSE_LOW));
which equates to
1. Enable clocks to port B
2. Set PTB13 to ALT3 function
You don't need to set the DDR since it is not used for peripheral functions.
If you get no output it is likely to be that the RTC is not operating.
Attached is a binary file that you can load to the FRDM-KL03Z which outputs the clock. Use a debugger to check the registers and compare to yours.
P.S. The PAD thing has to do with the fact that PTB13 GPIO and CLKOUT32K are shared. You can ignore it when using RTC_CLKOUT (ALT3 peripheral functions).