How to output RTC_CLKOUT on GPIO Pin in MKE1Z ? 

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to output RTC_CLKOUT on GPIO Pin in MKE1Z ? 

627 Views
rohini_doddaban
Contributor I

I have the below configuration to see RTC_CLKOUT on Port C pin 4. 

PCC_PORTC.PCCLK.BIT.CGC = 1;
PCIPORTC.PCR[4] = PORT_PCR_MUX(3);

ConfigGPIO(PORTC,4,OUTPUT_PUSHPULL);

RTC->CR = RTC_CR_CPE(3) | RTC_CR_CLKO(0)|RTC_CR_LPOS(0) | RTC_CR_CPS(1) |
RTC_CR_UM(0) | RTC_CR_SUP(0)| RTC_CR_OSCE(1);

But the Pin stays High always. Can anyone help me ?

Tags (1)
0 Kudos
3 Replies

457 Views
mjbcswitzerland
Specialist V

Hi

Beware that PTC4 is the SWD_CLK line and so using it as RTC_CLKOUT will cause the debugger to fail.

This is how I do it in the uTasker KE15Z project on PTC5:

1. Configure the pin function:
_CONFIG_PERIPHERAL(C, 5, (PC_5_RTC_CLKOUT | PORT_SRE_FAST | PORT_DSE_HIGH)); // configure the CLKOUT pin (the RTC must be operating for the signal to be present)

2. Enable the RTC
fnStartRTC(0);                                                   // start the RTC if it isn't yet operating

3. Set the 32kHz frequency to the output (automated in the last step when RTC_CLOCKOUT_ENABLE_32kHz is enabled)
RTC_CR |= (RTC_CR_CPE | RTC_CR_CPS_32k);                         // select 32kHz for output on RTC_CLKOUT
RTC_CR &= ~(RTC_CR_CLKO);                                        // allow the 32kHz signal to be passed to other peripherals


I have attached a FRDM-KE15Z binary that shows this operation (32kHz output on PTC15 - connector J1-12).
It has a command line interface on the OpenSDA VCOM at 115200 where the RTC can be requested/configured with time and date, plus alarms set.
In addition it has a memory debugger (menu 3) where you can look at internal registers in order to find differences between its setup and yours.

Make sure that your RTC is correctly operating if you have the pin mux set correctly but you don't have a signal.

Regards

Mark

Complete Kinetis solutions, training and support: http://www.utasker.com/kinetis.html
Kinetis: http://www.utasker.com/kinetis.html
Kinetis KE:
- http://www.utasker.com/kinetis/FRDM-KE02Z.html
- http://www.utasker.com/kinetis/FRDM-KE02Z40M.html
- http://www.utasker.com/kinetis/FRDM-KE04Z.html
- http://www.utasker.com/kinetis/FRDM-KE06Z.html
- http://www.utasker.com/kinetis/FRDM-KE15Z.html

0 Kudos

457 Views
rohini_doddaban
Contributor I

Thanks Mark!

I figured out that I did not select the Clock Source in SIM->CHIPCTL. 

I have a questions on OSC32_CR . Do we have to configure this register to use the EXTAL32 ? If yes , how do I access these. I am unable to write to these register. My system does not boot up as soon as I enable this.

pastedImage_1.png

0 Kudos

457 Views
mjbcswitzerland
Specialist V

Hi

1. If you needed to configure SIM->CHIPCTL it is because you are using a different RTC clock source than the OSC32.
2. To access the OSC32 you will need to first configure its clocking in the PCC.
3. If you enable the RTC oscillator in the RTC it will automatically set the OSC32 to crystal mode so no OSC32 configuration is needed for its basic operation.

Regards

Mark

0 Kudos