Properly round non integer bus-frequencies in MHz

PIT prescaler now rounds to nearest instead of down. Since when FLL is
used (default on KL05Z, but also possible on others), the bus
frequencies is 23.986MHz, rounding down is bad.
pull/174/head
Sissors 2014-02-18 18:40:33 +01:00
parent 8da53457ab
commit 65d66455c0
1 changed files with 1 additions and 1 deletions

View File

@ -44,7 +44,7 @@ static void pit_init(void) {
PIT->CHANNEL[1].TCTRL |= PIT_TCTRL_TEN_MASK; // Start timer 1
// Use channel 0 as a prescaler for channel 1
PIT->CHANNEL[0].LDVAL = bus_frequency() / 1000000 - 1;
PIT->CHANNEL[0].LDVAL = (bus_frequency() + 500000) / 1000000 - 1;
PIT->CHANNEL[0].TCTRL = PIT_TCTRL_TEN_MASK; // Start timer 0, disable interrupts
}