This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I tried to add Timer in the example "ble_app_uart"...

Hello ,

I use SDK 15.3 , chip is 52811

I refer to the example of 52840 "examples \ peripheral \ timer"

The following is the example code, I have not changed it.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const nrf_drv_timer_t TIMER_LED = NRF_DRV_TIMER_INSTANCE(0);
void timer_led_event_handler(nrf_timer_event_t event_type, void* p_context)
{
static uint32_t i;
uint32_t led_to_invert = ((i++) % LEDS_NUMBER);
switch (event_type)
{
case NRF_TIMER_EVENT_COMPARE0:
bsp_board_led_invert(led_to_invert);
break;
default:
//Do nothing.
break;
}
}
int main(void)
{
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Than, I am trying to add a Timer code to my project "ble_app_uart"

After adding main.c, I only modified 3 places.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/* ----- Timer1 ----- */
const nrf_drv_timer_t TIMER1_SPI_W25Q16 = NRF_DRV_TIMER_INSTANCE(1);
/* ----- I want USART Output ----- */
void timer_event_handler(nrf_timer_event_t event_type, void* p_context)
{
switch (event_type)
{
case NRF_TIMER_EVENT_COMPARE0:
app_uart_put(0x01);
break;
default:
//Do nothing.
break;
}
}
/* -----Maybe channel 0 corresponds to Timer0, I changed to channel 1 ----- */
nrf_drv_timer_extended_compare(
&TIMER1_SPI_W25Q16, NRF_TIMER_CC_CHANNEL1, time_ticks, NRF_TIMER_SHORT_COMPARE1_CLEAR_MASK, true);
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

And, sdk_config.h

Am I still missing a step? So Timer1 is not executed?

In addition, I would like to ask, what is NRFX?

Because there are two, "NRFX_TIMER_ENABLE" and "TIMER_ENABLED"

Thanks.