Hi All
I need a timer counter to count the time between a GPIO input pulse goes up and next pulse . I modified ble_app_hrs and use a one second timer interrupt to simulate GPIO interrupt . Every second start RTC1 and next second get the RTC1 count data.
Set the RTC1 at timers_init() and get RTC1 count data at one_second_timeout_handler().
Here are some program about RTC1.
#define ONE_SECODE_INTERVAL APP_TIMER_TICKS(1000) /**< one second timeout 1000ms >**/
APP_TIMER_DEF(m_one_second_timer_id); /**< second timer. */
static void timers_init(void)
{
..........
NRF_RTC1->PRESCALER = 327;
NRF_RTC1->TASKS_START = 1;
}
static void one_second_timeout_handler(void * p_context)
{
UNUSED_PARAMETER(p_context);
NRF_RTC1->TASKS_STOP = 1;
.......
.......
NRF_RTC1->TASKS_CLEAR = 1;
NRF_RTC1->TASKS_STOP = 0;
NRF_RTC1->TASKS_START = 1;
}
static void application_timers_start(void)
{
ret_code_t err_code;
// Start application timers.
// second interrupt
err_code = app_timer_start(m_one_second_timer_id, ONE_SECODE_INTERVAL, NULL);
APP_ERROR_CHECK(err_code);
}
This program works but I found if I change NRF_RTC1->PRESCALER then the timer interrupt timer interval changed also .Does the RTC1 used bye application timer ?
Regards
Tiger