This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Can I use RTC1?

I've just got up and running with the nRF51 DK. I've had a play with some of the examples, and now I've started on my own project using ble_app_template_s110_pca10028 as a starting point.

The first thing I would like to accomplish is to write some code which allows events to be scheduled for a specified day/hour/minute. The code might look something like...

calendar_set_current(MON, 10, 15); // called once at 10:15am to set the time ... calendar_schedule(TUES, 8, 30, blink_led_callback); // blinks led every tuesday at 8:30am

To do this, I would really like to take control of RTC1. However, it seems RTC1 is already in use by the app_timer module. On first glance, the interface provided by the app_timer module doesn't seem to fit my use case very well.

How much stuff will I break if I never initialize app_timer and instead use RTC1 for my own purposes? Will it affect the S110 soft device at all?

Alternatively, I could try to use the TIMER1 module instead. This will be a little more complicated, as this timer will overflow multiple times during the course of the week. But lets assume I can work around that. What would the power implications be? Does this mean the 16MHz crystal would need to be running all the time where otherwise it might have been able to sleep?

Parents
  • You can use RTC1 if you want, app_timer isn't a required module, don't include it and don't use it. However note that some other libraries (like the button debounce one) use app_timer, but not very many. If you use none of those, you can do whatever you like with RTC1. The softdevice doesn't use it at all, the softdevice doesn't depend on any of that user-space code.

    There's other options too. The app_timer code only uses one of the COMPARE registers on RTC1, the other ones are available for you to use if you want. So if you did need app_timer for say button debounce, you could still write your own code to use another of the compare registers. One point to note there is that the app_timer code will stop RTC1 running if it has no timers, so you'd need to keep one timer running. Or change app_timer.c to add your requirements, it's not particularly complicated code and you are free to modify it in any way you like, or write your own drop-in replacement.

    Most likely case sounds like you don't need app_timer, it's fairly unlikely you are using other modules which do need it so you can just leave it out and use RTC1 for whatever you like. I do, I don't use any of the library code, I have my own routines for buttons, timers, UART, SPI etc.

  • You said that Softdevice doesn't depend on app_timer. Are you sure? Because Keil says it needs it for ble_conn_params

Reply Children
No Data
Related