Skip to content

Update rtc_api.c #1506

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 29, 2016
Merged

Update rtc_api.c #1506

merged 1 commit into from
Jan 29, 2016

Conversation

star297
Copy link
Contributor

@star297 star297 commented Jan 17, 2016

Removed redundant RTC->CR define code + added RTC compensation code to allow calibration of the RTC.

Tom Russell found the RTC->CR settings in the rtc_api.c file overrode the OSC0->CR setting in system_MKL05Z4.c.
Effectively removing the internal loading capacitors for the external 32KHz crystal when the RTC is initialised.
If the external crystal 32Khz clock source is selected (default on the KL05), it is not necessary to call the RTC->CR functions. All other FRDM KLxx platforms RTC clock source is derived from the interface MCU.

Added RTC compensation function to allow calibration of the RTC.
This needs to be set in the rtc_init area, according to the manual, once the locks are enabled they can only be disabled with a POR or software reset making it difficult, probably impossible to place it in the user program code.

Removed redundant RTC->CR define code + added RTC compensation code to calibrate RTC.
@0xc0170
Copy link
Contributor

0xc0170 commented Jan 20, 2016

cc @Sissors

@Sissors
Copy link
Contributor

Sissors commented Jan 20, 2016

Can't we remove the OSC->CR overwriting in the rtc_api file, so the clock setup is done in the system file?

@star297
Copy link
Contributor Author

star297 commented Jan 20, 2016

That already happens in the clock set up Erik, hence removing the overwrite in the rtc_api.c
I can't think of any reason why it would be needed in the rtc_api.c it could only be relevant when the clock set up is using 32KHz external crystal. Other than using the internal slow 32KHz IRC to clock the RTC, but who is going to use that, too inaccurate.

The added compensation code does what is says on the box, but couldn't get this working in the main user code area which would be preferable to save modifying Mbed-dev files. According to the manual I believe the register locks are fixed after clock set up has initialised only to be released on POR or soft reset.
But I may have missed something.

@Sissors
Copy link
Contributor

Sissors commented Jan 20, 2016

My bad, I didn't properly read your code :(. This indeed seems good to me.

0xc0170 added a commit that referenced this pull request Jan 29, 2016
@0xc0170 0xc0170 merged commit d465cb5 into ARMmbed:master Jan 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants