Page 1 of 1

PIT issues.

Posted: Sun Apr 06, 2008 7:23 pm
by Fred
As noted in my firmware diary, I have issues with PIT. If anyone can figure out how they are supposed to work in my absense, that would be excellent.

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.
That's all folks, see you all in a few days! I'll be reading up on PIT's instead of looking at the view or being romantic (SO dedicated!) So, we'll see what we all come up with :-)

Admin.

Re: PIT issues.

Posted: Fri Apr 25, 2008 10:03 am
by Fred
I found in the manual that you should clear the flags before enabling the interrupts because they get set anyway. This shouldn't have affected me though as I didn't have the channels enabled pre enabling the interrupts. I tried clearing the flags before, no luck. I tried clearing them before and after, no luck.

Today I'm going to work on this some more and see where I get. If I have luck, I'll release 0.0.12, if not, I'll soldier on.

Sorry for the slow progress, but PIT isn't playing nice, also, things were a bit busy with admin stuff post release, and then I went away, and since I got back I had catch up to do, and now I'm working on getting a job too...

Fingers crossed todays efforts yield more results than before.

Admin.

Re: PIT issues.

Posted: Sat Apr 26, 2008 10:24 pm
by Fred
Progress :-)

Not "right" yet, but significantly improved :-)

Will keep you posted.

Admin.

Re: PIT issues.

Posted: Sat Apr 26, 2008 11:26 pm
by GartnerProspect
So does PIT stand for Pain In The...?

:D

Re: PIT issues.

Posted: Sun Apr 27, 2008 11:13 am
by Fred
Apparently yes :-)

(although, to be fair, I've spent far less time on it than I should have)

Re: PIT issues.

Posted: Mon Apr 28, 2008 10:58 am
by Fred
Did I mention that I'M AN IDIOT?

BAD MATH!! :-)

Yay :-)

Huston, we have something that can be fixed up and made into ignition! :-)

This thread is dead, like Zed.