Hi. I'm using PCA10028 and SDK10.0.0, S130 v1.0.0. And "ble_app_hrs_c" example is my reference code.
It works well before i add code for timer as below.
void start_timer(void) {
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer; // Set the timer in Counter Mode
NRF_TIMER2->TASKS_CLEAR = 1; // clear the task first to be usable for later
NRF_TIMER2->PRESCALER = 0; //Set prescaler. Higher number gives slower timer. Prescaler = 0 gives 16MHz timer
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit; //Set counter to 16 bit resolution
NRF_TIMER2->CC[0] = 32768; //Set value for TIMER2 compare register 0
NRF_TIMER2->CC[1] = 1; //Set value for TIMER2 compare register 1
// Enable interrupt on Timer 2, both for CC[0] and CC[1] compare match events
NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos) | (TIMER_INTENSET_COMPARE1_Enabled << TIMER_INTENSET_COMPARE1_Pos);
NVIC_EnableIRQ(TIMER2_IRQn);
NRF_TIMER2->TASKS_START = 1; // Start TIMER2
}
void TIMER2_IRQHandler(void) {
nrf_gpio_pin_toggle(GPIO_TOGGLE_PIN_1);
}
int main(void) { bool erase_bonds;
// Initialize.
APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL);
buttons_leds_init(&erase_bonds);
uart_init();
#if 1 // timer test nrf_gpio_cfg_output(GPIO_TOGGLE_PIN); start_timer(); #endif
....... }
It does'nt work well after i add "start_timer()" function. I don't understand. Can you tell me why? I hope your reply.