mirror of
git://projects.qi-hardware.com/ben-blinkenlights.git
synced 2024-11-24 01:37:32 +02:00
ubb-vga.c (delay): try to compensate for APB jitter (experimental)
First, we extend all deadlines a litte to make sure we never have to wait negative time. Second, we get the timer value at the end of the wait and CPU-loop for the difference between the actual value and the ideal (extended) value.
This commit is contained in:
parent
72235b9212
commit
01d33e28a7
@ -244,11 +244,17 @@ static void cleanup(void)
|
|||||||
static void delay(uint16_t cycles)
|
static void delay(uint16_t cycles)
|
||||||
{
|
{
|
||||||
static uint16_t next = 0;
|
static uint16_t next = 0;
|
||||||
|
uint16_t t;
|
||||||
|
|
||||||
next += cycles;
|
next += cycles;
|
||||||
TDHR(TIMER) = next;
|
TDHR(TIMER) = next;
|
||||||
TFCR = 1 << (TIMER+16);
|
TFCR = 1 << (TIMER+16);
|
||||||
while (!(TFR & (1 << (TIMER+16))));
|
while (!(TFR & (1 << (TIMER+16))));
|
||||||
|
t = next+24-TCNT(TIMER);
|
||||||
|
t >>= 1;
|
||||||
|
while (t--)
|
||||||
|
asm("");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user