A few references that I have found :
http://forums.freescale.com/freescale/b ... 3672#M2681
and
AN2724
And not a lot else.
here is my code :
Code: Select all
void init_pit_timer(void){
/* */
// set micro periods
PITMTLD0 = 0x1F; // approx 50ms
PITMTLD1 = 0x1F; // ditto
// set timers running
// PITLD0 = dwellPeriod;
// enable module
PITCFLMT = 0x80;
// enable channels
PITCE = 0x03;
// enable interrupt
// PITINTE = 0x01;
// clear flags
PITFLT = ONES;
}
Code: Select all
void IgnitionDwellISR(void)
{
// clear flag
PITTF = DWELL_ENABLE;
// turn off the int
PITINTE &= DWELL_DISABLE;
// start dwelling
PORTS_BA |= dwellStartMasks[nextDwellChannel];
// blink a led
PORTS ^= 0x80;
}
// TODO add in self schedule stuff for igntion timers, add in delay / latency corrections for that.
void IgnitionFireISR(void)
{
// clear the flag
PITTF = IGNITION_ENABLE;
// turn off the int
PITINTE &= IGNITION_DISABLE;
// fire the coil
PORTS_BA &= ignitionMasks[nextIgnitionChannel];
// blink a led
PORTS ^= 0x40;
}
Code: Select all
/* Schedule Dwell event (do this first because it comes earliest. */
/* Schedule Ignition event (do this first because it comes earliest. */
// set the channel to fire
nextDwellChannel = ignitionChannel;
// set the channel to fire
nextIgnitionChannel = ignitionChannel;
// set the time
PITLD0 = ignitionAdvances[ignitionChannel + outputBankIgnitionOffset] - currentDwell[outputBank];
// figure out the time to set the delay reg to
PITLD1 = ignitionAdvances[ignitionChannel + outputBankIgnitionOffset];
// force load micro timer
PITCFLMT |= 0x03;
// force load of that time
PITFLT |= DWELL_ENABLE;
// force load of that time
PITFLT |= IGNITION_ENABLE;
// turn on the ints
PITINTE |= (IGNITION_ENABLE | DWELL_ENABLE);
// clear the flags
PITTF |= (IGNITION_ENABLE | DWELL_ENABLE);
// issue lies here somewhere! TODO fix PIT operation.
Admin.