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

UART + Timer Issue NRF51

Hi,

I am using the following code to implement a millisecond timer read function. In main, while loop, I do nothing but run a 1ms delay and measure the time in mill second before and after and print the difference with uart over serial terminal. The output I get is 1ms but after every 12 odd readings I get 984ms as output and this continues.

Is this due to the uart or is there some issue with the timer implementation. Would appreciate the help. Thanks. 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include "boards.h"
#include "app_util_platform.h"
#include "app_uart.h"
#include "app_error.h"
#include "nrf_delay.h"
/*UART buffer size. */
#define UART_TX_BUF_SIZE 256
#define UART_RX_BUF_SIZE 1
uint32_t time;
#define MY_TIMER NRF_TIMER1
#define MY_TIMER_IRQn TIMER1_IRQn
#define MY_TIMER_IRQHandler TIMER1_IRQHandler
static uint32_t my_timer_seconds;
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX