Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 7 months ago.
External RTC for LPC11U24
Is there a way to hijack the standard Time API on the LPC11U24 in order to use an external i2c clock? I'd like to be able to use code written for the LPC1768 without re-writing it to use a custom time library.
1 Answer
10 years, 7 months ago.
I think you might be able to do the following:
- Copy this source file into your LPC11U24 project: https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/common/rtc_time.c The version of this code in the mbed library for LPC11U24 would have had DEVICE_RTC set to 0. You would #define it to have a value of 1 at the top of your version.
- You then need to provide an implementation of the rtc_api functions which interface to your i2c clock. You can see an example implementation for the LPC1768 here: https://github.com/mbedmicro/mbed/blob/master/libraries/mbed/targets/hal/TARGET_NXP/TARGET_LPC176X/rtc_api.c
I hope that helps,
Adam
I think you indeed will need to modify the mbed library. Small note, you can in the online compiler simply throw away your mbed lib and import: http://mbed.org/users/mbed_official/code/mbed-src/.
posted by 29 Aug 2013Thanks! I copied and modified rtc_api.h, rtc_api.c, and rtc_time.c and I was able to read a dummy time. My question would be is this hack very stable? How does that work when both the mbed library, and my hack library supply a version of rtc_api.h and rtc_time.c? Can I be guaranteed my version will always be compiled first? I published the hack library here: http://mbed.org/users/neilt6/code/RTC_Hack/
posted by 29 Aug 2013The linker should give your implementation higher priority since the other comes from a library (mbed). If it was to get confused, it would try to pull in two implementations of the same function and this would cause an error to be thrown from the linker due to duplication definitions. So if something does go wrong you shouldn't get an unstable build, you should get no build at all.
posted by 29 Aug 2013