hi, i am going to make a simple timer with SDK 6.0.0, nrf51822 and softdevice.
first, i use ble_app_uart example as a base code, because i need to BLE communication with high frequency.
here is my simple code
int main(void) {
// Initialize
leds_init();
timers_init();
buttons_init();
// uart_init(); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); sec_params_init(); nrf_gpio_cfg_output(22);
//NRF_CLOCK->EVENTS_HFCLKSTARTED = 0;
NRF_CLOCK->TASKS_HFCLKSTART;
//Wait for external oscillator to start up
NRF_TIMER2->PRESCALER = 4;
NRF_TIMER2->TASKS_CLEAR;
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_16Bit;
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER2->EVENTS_COMPARE[0] = 0;
NRF_TIMER2->CC[0] = 400;
NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos);
NVIC_EnableIRQ(TIMER2_IRQn);
NRF_POWER->TASKS_CONSTLAT;
NRF_TIMER2->TASKS_START;
// simple_uart_putstring(START_STRING);
advertising_start();
// Enter main loop
for (;;)
{
//power_manage();
}
}
void TIMER2_IRQHandler(void) { NRF_TIMER2->EVENTS_COMPARE[0] = 0; NRF_TIMER2->TASKS_CLEAR; nrf_gpio_pin_toggle(22); nrf_gpio_pin_toggle(21); nrf_gpio_pin_toggle(20); }
the BLE connection is operated well with BLE toolbox. But the timer2 compare interrupt is never called.
and i cannot use the RTS timer with app_timer function because i need more 1/32767 Hz
There is anything that i missed???