Skip to content
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

RTC not implemented #51

Closed
dhofstetter opened this issue May 5, 2016 · 8 comments
Closed

RTC not implemented #51

dhofstetter opened this issue May 5, 2016 · 8 comments

Comments

@dhofstetter
Copy link

Can anyone explain the reasons why the RTC of the nrf51822 is not usable with mbed? I read some comments within us_ticker.c that show that the RTC1 is in use for regular ticker and scheduling due to power consumption (Low frequency timers compared to High frequency ones).

But I haven't found that RTC0 is already in use by one of the library implementations! Is it therefore possible to use this for the rtc_api.c implementation?

BR Daniel

@0xc0170
Copy link
Contributor

0xc0170 commented May 5, 2016

RTC0 is used by softdevice.

@dhofstetter
Copy link
Author

dhofstetter commented May 5, 2016

Ahh ok, thanks for the information.

Might be a stupid question, but what is a softdevice?

As the LFTimer is already in use for us_ticker it is not possible to use it for RTC also. I mean in the way that rtc_api.c is implemented, correct?

Edit: I think of some changes that may enable the usage of the rtc interrupt for both rtc_api.c and us_ticker.c
Maybe implementing an additional file that abstracts the rtc timer usage so that both us_ticker and rtc_api get invoked in case of the interrupt. And either of them can enable the rtc1 when they need it. Do you think that might be possible? In case I will try to do so tomorrow.

BR

@ciarmcom
Copy link
Member

ciarmcom commented May 6, 2016

ARM Internal Ref: IOTSFW-2522

@dhofstetter
Copy link
Author

I think I found a way to implement the rtc without having huge changes, but my question is where to make sure that the DEFINE has to be set that the implementation get recognized?

@0xc0170
Copy link
Contributor

0xc0170 commented May 6, 2016

softdevice info : https://www.nordicsemi.com/eng/Products/S110-SoftDevice-v7.0

there're some RTC1 channels left, so you might get it working to provide rtc time functionality. You can describe more in detail, or just send a pull request for review.

@dhofstetter
Copy link
Author

dhofstetter commented May 6, 2016

Within my fork you can see or review the changes. If I will do a pull request again, I thing it's going to the blenano one again. That is not correctly I think.

I have a problem compiling my rtc changes, because the compiler outputs:

info: generate for target: blenano15-gcc 1.0.0 at /home/dhofstetter/Development/Privat/BLENano/secondBLETest/yotta_targets/blenano15-gcc
GCC version is: 5.3.1
suppressing warnings from nrf51-sdk
omit frame pointer for bootloader startup asm
suppressing warnings from ble-nrf51822
-- Configuring done
-- Generating done
-- Build files have been written to: /home/dhofstetter/Development/Privat/BLENano/secondBLETest/build/blenano15-gcc
[1/1] Linking CXX executable source/firstble
FAILED: : && /opt/gcc/gcc-arm-none-eabi/bin/arm-none-eabi-g++   -fno-exceptions -fno-unwind-tables -Wl,--gc-sections -Wl,--sort-common -Wl,--sort-section=alignment -Wl,-wrap,main -Wl,-u,_printf_float -mcpu=cortex-m0 -mthumb -T"/home/dhofstetter/Development/Privat/BLENano/secondBLETest/yotta_targets/nordic-nrf51822-gcc/CMake/../ld/NRF51822_32K_S130.ld" -Wl,-Map,source/firstble.map -Wl,--start-group source/CMakeFiles/firstble.dir/home/dhofstetter/Development/Privat/BLENano/secondBLETest/source/app.cpp.o  ym/mbed-hal-blenano/source/mbed-hal-blenano.a ym/ble/source/ble.a ym/ble-nrf51822/source/ble-nrf51822.a ym/ble/source/ble.a ym/ble-nrf51822/source/ble-nrf51822.a ym/mbed-hal-blenano/source/mbed-hal-blenano.a ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a ym/mbed-drivers/source/mbed-drivers.a ym/mbed-hal/source/mbed-hal.a ym/mbed-hal-nordic/yotta_dummy_lib_mbed_hal_nordic/mbed-hal-nordic.a ym/cmsis-core/source/cmsis-core.a ym/minar/source/minar.a ym/core-util/source/core-util.a ym/cmsis-core-nordic/yotta_dummy_lib_cmsis_core_nordic/cmsis-core-nordic.a ym/minar-platform/yotta_dummy_lib_minar_platform/minar-platform.a ym/cmsis-core-nrf51822/source/cmsis-core-nrf51822.a ym/minar-platform-mbed/source/minar-platform-mbed.a ym/nrf51-sdk/source/nrf51-sdk.a ym/mbed-hal-blenano/source/mbed-hal-blenano.a ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a ym/mbed-drivers/source/mbed-drivers.a ym/mbed-hal/source/mbed-hal.a ym/mbed-hal-nordic/yotta_dummy_lib_mbed_hal_nordic/mbed-hal-nordic.a ym/cmsis-core/source/cmsis-core.a ym/minar/source/minar.a ym/core-util/source/core-util.a ym/cmsis-core-nordic/yotta_dummy_lib_cmsis_core_nordic/cmsis-core-nordic.a ym/minar-platform/yotta_dummy_lib_minar_platform/minar-platform.a ym/cmsis-core-nrf51822/source/cmsis-core-nrf51822.a ym/minar-platform-mbed/source/minar-platform-mbed.a ym/nrf51-sdk/source/nrf51-sdk.a ym/compiler-polyfill/yotta_dummy_lib_compiler_polyfill/compiler-polyfill.a ym/ualloc/source/ualloc.a ym/dlmalloc/source/dlmalloc.a -Wl,-wrap,_malloc_r -Wl,-wrap,_calloc_r -Wl,-wrap,_realloc_r -Wl,-wrap,_free_r -Wl,-wrap,_sbrk_r ym/greentea-client/source/greentea-client.a  -lstdc++ -lsupc++ -lm -lc -lgcc -lstdc++ -lsupc++ -lm -lc -lgcc -Wl,--end-group  --specs=nano.specs -o source/firstble && cd /home/dhofstetter/Development/Privat/BLENano/secondBLETest/build/blenano15-gcc/source && arm-none-eabi-objcopy -O ihex firstble firstble.hex && python /home/dhofstetter/Development/Privat/BLENano/secondBLETest/yotta_targets/nordic-nrf51822-gcc/CMake/../scripts/merge_hex.py /home/dhofstetter/Development/Privat/BLENano/secondBLETest/yotta_targets/nordic-nrf51822-gcc/CMake/../softdevice/s130_nrf51_1.0.0_softdevice.hex firstble.hex firstble-combined.hex && cd /home/dhofstetter/Development/Privat/BLENano/secondBLETest/build/blenano15-gcc/source && python /home/dhofstetter/Development/Privat/BLENano/secondBLETest/yotta_targets/nordic-nrf51822-gcc/CMake/../scripts/memory_info.py firstble 1024 && cd /home/dhofstetter/Development/Privat/BLENano/secondBLETest/build/blenano15-gcc/source && /opt/gcc/gcc-arm-none-eabi/bin/arm-none-eabi-objcopy -O binary firstble firstble.bin
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `RTC1_IRQHandler':
/home/dhofstetter/Development/Privat/BLENano/secondBLETest/yotta_modules/mbed-hal-nrf51822-mcu/source/us_ticker.c:164: undefined reference to `rtc_read'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed.
error: command ['ninja'] failed

For me that seems as, the include of "rtc_api.h" won't work. Because for my target the blenano I already activated the DEVICE_RTC Define to 1 and also checked with a define "error message" that DEVICE_RTC is really defined to 1. I'm not sure why it's not working because if I look into rtc_api.h I can see the function rtc_read(void)

Edit: By left rtc channels you mean something like the CC register based solution within lp_ticker.c?

BR Daniel

@dhofstetter
Copy link
Author

I changed the way of implementation today. Now I can compile but all of my functions (I added an rtc_int.h and rtc_int.c file) are not accessible, yotta says there is no reference. You can have a look to the changes at my fork!

ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `rtc1_captureCompareEventHandler':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:50: undefined reference to `rtc1_getCounter'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `invokeCallback':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:44: undefined reference to `rtc1_disableCaptureCompareEventReg0'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `us_ticker_init':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:62: undefined reference to `rtc1_setCaptureCompareEventHandlerReg0'
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:63: undefined reference to `rtc1_start'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `us_ticker_read':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:75: undefined reference to `rtc1_getCounter64'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `us_ticker_set_interrupt':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:119: undefined reference to `rtc1_getCounter64'
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:136: undefined reference to `rtc1_getCounter'
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:137: undefined reference to `rtc1_getCounter'
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:142: undefined reference to `rtc1_setCaptureCompareValueReg0'
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:147: undefined reference to `rtc1_enableCaptureCompareEventReg0'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `us_ticker_disable_interrupt':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:154: undefined reference to `rtc1_disableCaptureCompareEventReg0'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(us_ticker.c.o): In function `us_ticker_clear_interrupt':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/us_ticker.c:163: undefined reference to `rtc1_clearCaptureCompareEventReg0'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(lp_ticker.c.o): In function `lp_ticker_init':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/lp_ticker.c:28: undefined reference to `rtc1_start'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(lp_ticker.c.o): In function `lp_ticker_read':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/lp_ticker.c:33: undefined reference to `rtc1_getCounter'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(lp_ticker.c.o): In function `lp_ticker_get_compare_match':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/lp_ticker.c:54: undefined reference to `rtc1_getCaptureCompareValueReg1'
ym/mbed-hal-nrf51822-mcu/existing/mbed-hal-nrf51822-mcu.a(lp_ticker.c.o): In function `lp_ticker_set_interrupt':
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/lp_ticker.c:43: undefined reference to `rtc1_setCaptureCompareValueReg1'
/home/dhofstetter/Development/Privat/BLENano/mbed-hal-nrf51822-mcu/source/lp_ticker.c:44: undefined reference to `rtc1_enableCompareEventReg1'

@dhofstetter
Copy link
Author

Finally I got it working, just have a look at PullRequest #52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants