Skip to content

fix timestamps on received packets - #3

Open
esaulenka wants to merge 1 commit into
smartgauges:mainfrom
esaulenka:fix-timestamps
Open

fix timestamps on received packets#3
esaulenka wants to merge 1 commit into
smartgauges:mainfrom
esaulenka:fix-timestamps

Conversation

@esaulenka

Copy link
Copy Markdown
Contributor

Systick - странная штука, внутренний счётчик там считает вниз, от reload value до нуля.
Соответственно, при использовании этого счётчика надо менять его знак.

Проверил на 100% загруженной 500k шине, теперь пакеты имеют корректные таймштампы с разницей 230..250 микросекунд.
Проблема с изменением порядка по-прежнему есть, разбираюсь...

Comment thread tick.c

volatile tick_t tick = { 0, 0, 0, 0, 0, 0 };
volatile uint32_t usecs = 0;
static volatile uint32_t usecs = 1000;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this monotonic counter in microseconds increases by 1000 every 1 ms, must be initialized to 0

Comment thread tick.c

value += (1000 * v) / systick_get_reload();
// sysick counts DOWN!
value -= (1000 * v) / systick_get_reload();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it makes more sense to add a fraction of a millisecond, how do you think?
value += (1000 * (systick_get_reload() - v)) / systick_get_reload();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants