Modifying code

This is a forum for discussing the development and testing of alpha MS2/Extra code. Documentation
(Runs on MS2 and Microsquirt)

Moderators: jsmcortina, muythaibxr

Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Modifying code

Post by Keithg »

I tried the make.bat file in the src directory. How do we recompile MS2/E?

KeithG
muythaibxr
Site Admin
Posts: 8228
Joined: Thu Oct 14, 2004 12:48 pm

Post by muythaibxr »

You have to get the gcc package that was put together, or you have to go get cygwin and download the compiler package, and then build it inside cygwin.

The gcc package is here:

http://prdownloads.sourceforge.net/mega ... p?download

Ken
Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Post by Keithg »

Any problems with using GCC? That is my first choice.

KeithG
muythaibxr
Site Admin
Posts: 8228
Joined: Thu Oct 14, 2004 12:48 pm

Post by muythaibxr »

Your question doesn't make sense. You HAVE to use gcc, either the latest package from the gcc for hcs12 site, or the one that I linked in my last post on this thread.

EDIT:

Planning on adding a new feature?

EDIT2: Maybe my previous post wasn't clear... You either have to get the package that I posted a link to above, or get cygwin, and download the latest gcc package from the hcs12 site. Either way you're using gcc.

With cygwin, you get close to a real UNIX-like environment, so you can use things like make, and patch.

Ken
Last edited by muythaibxr on Tue Aug 14, 2007 8:31 am, edited 1 time in total.
Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Modifying code

Post by Keithg »

Oh. Sorry, I was not clear...

I had heard (read) a while back that someone was having trouble with
GCC making bloated or possibly incorrect code. I'd rather use GCC
unless there is a distinct advantage in the code created using Cygwin.

KeithG


On 8/14/07, muythaibxr wrote:

Your question doesn't make sense. You HAVE to use gcc, either the latest
package from the gcc for hcs12 site, or the one that I linked in my last
post on this thread.

Ken
Last edited by Keithg on Fri Aug 17, 2007 10:38 pm, edited 1 time in total.
rb26dett
Master MS/Extra'er
Posts: 497
Joined: Tue May 24, 2005 11:34 pm
Location: Auckland New Zealand

Post by rb26dett »

cygwin is a win package so that it acts like linux. you have to use gcc whether its wrapped in cygwin or raw in windows, or raw in linux...

no other way without back porting the code to codewarrior and fixing all the stuff that will break and paying for an expensive version to handle the size.

hope that helps.

fred.
ms2,v3,cop,innovate,mazda fe3/fe-dohc 2l 4cyl with stock 10:1 pistons,4 stock coils,4 stock ignitors,rx7 550cc injectors maxed@6600rpm&17psi,custom everything,holset he351cw turbo,44mm ext gate,nis gtr bovs,nis gtr intercooler,70mm lexus throttle,chinese fpr,10may v2 ms2e alpha code
muythaibxr
Site Admin
Posts: 8228
Joined: Thu Oct 14, 2004 12:48 pm

Re: Modifying code

Post by muythaibxr »

Keithg wrote:Oh. Sorry, I was not clear...

Cygwin doesn't generate the code... you download the compiler and use it from cygwin, or you download from the link above, and use that. Either way you're using gcc, it's just a matter of the environment you compile from. The generated code is the same either way.

You planning a new feature?

Ken
Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Modifying code

Post by Keithg »

Ok, now it is a bit more clear. Sorry I was not as well informed as I probably should have been. I was used to MS1/E and just clicked compile... This is just a bit more complicated for us MEs.

No new features, just trying to learn C so that I can play around a bit.

KeithG

On 8/14/07, muythaibxr wrote:
Keithg wrote: Oh. Sorry, I was not clear...


Cygwin doesn't generate the code... you download the compiler and use it from cygwin, or you download from the link above, and use that. Either way you're using gcc, it's just a matter of the environment you compile from. The generated code is the same either way.

You planning a new feature?

Ken

muythaibxr
Site Admin
Posts: 8228
Joined: Thu Oct 14, 2004 12:48 pm

Post by muythaibxr »

I should be pretty familiar to anyone who's done any work in Linux/FreeBSD/*nix. If you haven't done that then it's understandable that it's not that familiar.

In either case, once you have the tools you need, it's not difficult... it's as simple as double clicking make.bat, or typing "make" on the commandline.

Ken
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Post by jsmcortina »

As Ken says, we only use gcc. While it does generate some bloated code, we've done our best to work around that.

You'll also need to learn HCS12 assembly. Not that different from HC08 assembly though.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Post by Keithg »

Ok, I have tried one modification with the 0812 package. I grabbed the GCC package as instructed. I Modified the code. It compiled (no errors) and I was able to U/L the new S19 to the MS. I calibrated sensors, I loaded the latest MSQ and all looks good. When I try to crank it, the MT screen goes red (disconnect) and it locks on the fuel pump. I have to power down and wait a minute then I can reload the original S19 file and all is well again. Is this an indication that I made some syntax or other programming error, or am I doing something else odd.

All I edited was the *misc.c file. and I double clicked on make.bat then uploaded the s19 file that was created in the directory.

KeithG
Last edited by Keithg on Fri Aug 24, 2007 9:04 am, edited 1 time in total.
jsmcortina
Site Admin
Posts: 39585
Joined: Mon May 03, 2004 1:34 am
Location: Birmingham, UK
Contact:

Post by jsmcortina »

You've missed an opening brace out of
} else if (IdleCtl == 6)

The other thing worth trying is to compile the stock code and make sure it works the same as the bundled s19. That way you know that your compiler and build environment is working correctly.
Another tip - update sigs.c as you work. This way you'll get confirmation via the date/time in the Megatune title that you have uploaded the correct code.

James
I can repair or upgrade Megasquirts in UK. http://www.jamesmurrayengineering.co.uk

My Success story: http://www.msextra.com/forums/viewtopic ... 04&t=34277
MSEXTRA documentation at: http://www.msextra.com/doc/index.html
New users, please read the "Forum Help Page".
efahl
Super MS/Extra'er
Posts: 2793
Joined: Mon Feb 16, 2004 4:15 pm
Location: San Clemente, California, USA
Contact:

Post by efahl »

jsmcortina wrote:Another tip - update sigs.c as you work. This way you'll get confirmation via the date/time in the Megatune title that you have uploaded the correct code.
Don't you do this automatically? Just use the predefined symbols __DATE__ and __TIME__ to embed the compile time into the code:

char *sig = "MSe-II " __DATE__ " " __TIME__;
muythaibxr
Site Admin
Posts: 8228
Joined: Thu Oct 14, 2004 12:48 pm

Post by muythaibxr »

IF that's something cvs does, then keith can't do it as he doesn't have CVS access.

Ken
Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Post by Keithg »

Well, I am able to compile the MS2/E code as delivered. It uploads and works as far as I can tell exactly as the released S19. The only thing I noticed is that the S19 I generated is smaller than the one in the released package. Mine is 172kb and the released version is 183 kb.

I went through it and cannot see where I am missing a brace. I am using notepad++ and it highlights the braces and parentheses. Is there an editor for the HC12 which is more 'helpful' with this?

KeithG
jsmcortina wrote:You've missed an opening brace out of
} else if (IdleCtl == 6)

The other thing worth trying is to compile the stock code and make sure it works the same as the bundled s19. That way you know that your compiler and build environment is working correctly.
Another tip - update sigs.c as you work. This way you'll get confirmation via the date/time in the Megatune title that you have uploaded the correct code.

James
efahl
Super MS/Extra'er
Posts: 2793
Joined: Mon Feb 16, 2004 4:15 pm
Location: San Clemente, California, USA
Contact:

Post by efahl »

muythaibxr wrote:IF that's something cvs does, then keith can't do it as he doesn't have CVS access.
These predefined macros are part of the C-preprocessor and have been around for decades. They are now part of the ISO standard for the language, along with a handful of others.

http://www.linuxtopia.org/online_books/ ... NED-MACROS
muythaibxr
Site Admin
Posts: 8228
Joined: Thu Oct 14, 2004 12:48 pm

Post by muythaibxr »

Haha, I didn't know that was built into C!

I've been a software engineer doing mainly C for 7-8 years, and have never once seen that used.

Learn something new everyday I guess.

Ken
Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Post by Keithg »

Ok, As I previously said, I am not a programmer, so this is a bit hard for me. I have been able to compile and load code, but this test does not seem to work. The bit I am trying to modify is:

Code: Select all

if (outpc.tps > (int)flash5.pwmidle_tps_thresh) {
		    if (outpc.rpm > rpm_thresh) {
			DISABLE_INTERRUPTS;
			IACmotor_pos = flash5.pwmidle_closed_duty;
			ENABLE_INTERRUPTS;
		    }
		    if (IACmotor_reset == 0) {
			IACmotor_reset = 1;
		    }
		    DISABLE_INTERRUPTS;
		    idle_wait_timer = 0;
		    ENABLE_INTERRUPTS;
		    last_rpm = outpc.rpm;
		}
I want to change the first part to

Code: Select all

if ((outpc.tps > (int)flash5.pwmidle_tps_thresh) || 
                (outpc.rpm > rpm_thresh)){
		    {
			DISABLE_INTERRUPTS; ...
The code compiles, but it never will allow the OR test. It does not matter if the order is reversed (rpm first then tps). It only acts on the TPS test. What am I missing?

KeithG
Last edited by Keithg on Fri Aug 24, 2007 8:07 am, edited 1 time in total.
Smog Fighter
Experienced MS/Extra'er
Posts: 152
Joined: Sat May 12, 2007 10:37 pm
Location: Bakersfield, Ca

Post by Smog Fighter »

Keithg wrote:Ok, As I previously said, I am not a programmer, so this is a bit hard for me. I have been able to compile and load code, but this test does not seem to work. The bit I am trying to modify is:

Code: Select all

if (outpc.tps > (int)flash5.pwmidle_tps_thresh) {
		    if (outpc.rpm > rpm_thresh) {
			DISABLE_INTERRUPTS;
			IACmotor_pos = flash5.pwmidle_closed_duty;
			ENABLE_INTERRUPTS;
		    }
		    if (IACmotor_reset == 0) {
			IACmotor_reset = 1;
		    }
		    DISABLE_INTERRUPTS;
		    idle_wait_timer = 0;
		    ENABLE_INTERRUPTS;
		    last_rpm = outpc.rpm;
		}
I want to change the first part to

Code: Select all

if ((outpc.tps > (int)flash5.pwmidle_tps_thresh) || 
                (outpc.rpm > rpm_thresh){
		    {
			DISABLE_INTERRUPTS; ...
The code compiles, but it never will allow the OR test. It does not matter if the order is reversed (rpm first then tps). It only acts on the TPS test. What am I missing?

KeithG


You are missing a ")" at the end of the expression.
if ((outpc.tps > (int)flash5.pwmidle_tps_thresh) ||
(outpc.rpm > rpm_thresh)){
{
DISABLE_INTERRUPTS; ...[/code]
ahta should get it to compile.
Raul

soon to be squirt&sparked 89 mkIII Supra, Using:
MS2 processor (pins 10 & 15 modded), v3.0pcb,
stepper IAC, P&H boards, *ERROR -extra board,
in 6cyl wasted spark configuration.
Jun-10-2007 alpha code.
Keithg
Super MS/Extra'er
Posts: 2413
Joined: Sun Mar 06, 2005 9:15 am
Location: Chicago, IL, USA
Contact:

Post by Keithg »

Raul,

Thanks, but that was a typo on my part. I have that parentheses closed and edited my code listed above. I can get it to compile, and all looks good, but it ignores the test for the RPMs above the threshold.

Could it be that this is set up like:

If (test) {stuff with if statements}
Else {stuff with if statements}

that it seems to ignore the OR statement in the first IF?

KeithG
Post Reply