febb: (Default)
[personal profile] febb
Вчера полчаса полировал програмку из предыдущего поста.
Оптимальный подход в обработке системного таймера для получения точности в секундах
это использовать инкремент и переполнение счетчика, примерно так:
byte Seconds;
void UpdateTimers()
{
	static const short long int inc = xxxxxxx;
	static short long int cnt = 0;
	static byte timer;
	byte t = TMR0; // Read system timer
	if(t < timer) // timer rollover
	{
		cnt += inc;
		if(cnt < inc) // roll over every second
		{
			++Seconds;	// Increment seconds
			//........... more code ......
		}     

	}
	timer = t;
}

Profile

febb: (Default)
febb

March 2022

S M T W T F S
  1 2 345
6 7 89 101112
13141516171819
20212223242526
2728293031  

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 10th, 2026 02:31 pm
Powered by Dreamwidth Studios