Hi,
I am using pca10040 board. i need to toggle a led in 5sec once. I tried to change the prescale value. But im not able to get that much time delay.
Can any one help me on this?
Hi Ole Bauck,
If i set prescale value 9 and bitmode is 32 means. The counting will be start in 0 to 4,294,967,296. For 5 second delay i set cc[0]=156250. For my requirement i need continuously toggle a led for 5 mins. At very first time its coming in 5 second [0 - 156250] but after that its taking more time [156270 - 4,294,967,296] I dont kw how to do that..
can u guide me on thz.. below is my function:
void start_timer(void)
{
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER2->TASKS_CLEAR = 1;
NRF_TIMER2->PRESCALER = 9;
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_32Bit;
NRF_TIMER2->CC[0] = 156250;
NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos) ;
NVIC_EnableIRQ(TIMER2_IRQn);
NRF_TIMER2->TASKS_START = 1;
}
void TIMER2_IRQHandler(void)
{
if ((NRF_TIMER2->EVENTS_COMPARE[0] != 0))
{
NRF_TIMER2->EVENTS_COMPARE[0] = 0;
NRF_TIMER2->CC[0] += 156250;
nrf_gpio_pin_toggle(GPIO_TOGGLE_PIN);
}
}
Hi Ole Bauck,
If i set prescale value 9 and bitmode is 32 means. The counting will be start in 0 to 4,294,967,296. For 5 second delay i set cc[0]=156250. For my requirement i need continuously toggle a led for 5 mins. At very first time its coming in 5 second [0 - 156250] but after that its taking more time [156270 - 4,294,967,296] I dont kw how to do that..
can u guide me on thz.. below is my function:
void start_timer(void)
{
NRF_TIMER2->MODE = TIMER_MODE_MODE_Timer;
NRF_TIMER2->TASKS_CLEAR = 1;
NRF_TIMER2->PRESCALER = 9;
NRF_TIMER2->BITMODE = TIMER_BITMODE_BITMODE_32Bit;
NRF_TIMER2->CC[0] = 156250;
NRF_TIMER2->INTENSET = (TIMER_INTENSET_COMPARE0_Enabled << TIMER_INTENSET_COMPARE0_Pos) ;
NVIC_EnableIRQ(TIMER2_IRQn);
NRF_TIMER2->TASKS_START = 1;
}
void TIMER2_IRQHandler(void)
{
if ((NRF_TIMER2->EVENTS_COMPARE[0] != 0))
{
NRF_TIMER2->EVENTS_COMPARE[0] = 0;
NRF_TIMER2->CC[0] += 156250;
nrf_gpio_pin_toggle(GPIO_TOGGLE_PIN);
}
}