PIT issues.

Official FreeEMS vanilla firmware development, the heart and soul of the system!
Post Reply
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

PIT issues.

Post 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.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PIT issues.

Post 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.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PIT issues.

Post by Fred »

Progress :-)

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

Will keep you posted.

Admin.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
GartnerProspect
LQFP112 - Up with the play
Posts: 160
Joined: Tue Apr 08, 2008 9:14 pm

Re: PIT issues.

Post by GartnerProspect »

So does PIT stand for Pain In The...?

:D
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PIT issues.

Post by Fred »

Apparently yes :-)

(although, to be fair, I've spent far less time on it than I should have)
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
User avatar
Fred
Moderator
Posts: 15431
Joined: Tue Jan 15, 2008 2:31 pm
Location: Home sweet home!
Contact:

Re: PIT issues.

Post 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.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Post Reply