Hi,
I have a Unix time stamp value stored on the Nordic board that comes from a GATT connection.
I am using SDK 15 s140 pca10056 NRF52840-dk.
I need to update this value once per second so that I have an accurate timestamp for my data which, I store to an SD card. I tried combining a calendar example however, this did not work with the Bluetooth initialised just crashed. Therefore, how can I go about creating something that can increment the counter by 1 each second. I am thinking of using RTC but, am struggling to set this up.
Looking at the RTC example within the SDK it allows a LED 1. To blink rapidly. The LED 2 turns on after 3 second. Would it be possible to change LED 1 to increment the counter by one and run this once per second.
/** @brief Function configuring gpio for pin toggling.
*/
static void leds_config(void)
{
bsp_board_init(BSP_INIT_LEDS);
}
/** @brief Function starting the internal LFCLK XTAL oscillator.
*/
static void lfclk_config(void)
{
ret_code_t err_code = nrf_drv_clock_init();
APP_ERROR_CHECK(err_code);
nrf_drv_clock_lfclk_request(NULL);
}
/** @brief Function initialization and configuration of RTC driver instance.
*/
static void rtc_config(void)
{
uint32_t err_code;
//Initialize RTC instance
nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG;
config.prescaler = 4095;
err_code = nrf_drv_rtc_init(&rtc, &config, rtc_handler);
APP_ERROR_CHECK(err_code);
//Enable tick event & interrupt
nrf_drv_rtc_tick_enable(&rtc,true);
//Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds
err_code = nrf_drv_rtc_cc_set(&rtc,0,COMPARE_COUNTERTIME * 8,true);
APP_ERROR_CHECK(err_code);
//Power on RTC instance
nrf_drv_rtc_enable(&rtc);
}
Thanks,