New Code Help. (Code Gurus Needed)
#1
Evolving Member
Thread Starter
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes
on
0 Posts
New Code Help. (Code Gurus Needed)
I've been writing a set of Mods for the H8 ecus, like a dumbed down version of the Tephra Mods.
The H8s are in 98-00 cars, Evo5/6, DSM, 3000GT, etc.
I have about half the Mods working, but am having some trouble with the others.
Hopefully some of the wise code gurus on this forum could offer some insight, sometimes I miss something obvious and need someone to point it out for me.
My Mods so far:
2-Step(Stationary RevLimit) - Works 100%
Checks vehicle speed, if lower use 2-Step Limit, if higher use RevLimit.
AntiLag - Not working
A couple hundred rpm before the 2-Step Limit is reached, timing is retarded to help build boost.
CEL on Knock - Not working
CEL lights once a certain knock count is exceeded.
Map Select - Not fully tested yet
Many H8s have a second set of maps that are not used. This allows them to be easily selected.
I know this isn't the SH-2 code everyone is use to, but I think the H8 is a lot easier to understand.
All references to the normal RevLimit were replaced with the memory location FD00.
My code is hooked in after the Timing Map Lookup, TimAdvC_F458 is what that lookup is loaded into.
Does anyone know if the OBD code will interfere you trying to light the CEL?
And if you are try to control timing, where is the best spot to do so?
If my code isn't clear, can add comments.
Anyone see any mistakes? Been bang my head off this for hours.
The H8s are in 98-00 cars, Evo5/6, DSM, 3000GT, etc.
I have about half the Mods working, but am having some trouble with the others.
Hopefully some of the wise code gurus on this forum could offer some insight, sometimes I miss something obvious and need someone to point it out for me.
My Mods so far:
2-Step(Stationary RevLimit) - Works 100%
Checks vehicle speed, if lower use 2-Step Limit, if higher use RevLimit.
AntiLag - Not working
A couple hundred rpm before the 2-Step Limit is reached, timing is retarded to help build boost.
CEL on Knock - Not working
CEL lights once a certain knock count is exceeded.
Map Select - Not fully tested yet
Many H8s have a second set of maps that are not used. This allows them to be easily selected.
I know this isn't the SH-2 code everyone is use to, but I think the H8 is a lot easier to understand.
Code:
seg000:1600 F0 80 ModBits: .word 0xF080 seg000:1602 03 E8 RevLimit: .word 0x3E8 seg000:1604 00 08 SpeedOff: .word 8 seg000:1606 07 D0 TwoStepLimit: .word 0x7D0 seg000:1608 08 F8 AntiLagRPM: .word 0x858 seg000:160A F6 FF IgnRetard: .word 0xF6FF seg000:160C 00 03 KnockCnt4CEL: .word 3 RAM:0000FD00 ?? ?? Limit_FD00: .space 2
Code:
seg002:2E1D0 ! =============== S U B R O U T I N E ======================================= seg002:2E1D0 seg002:2E1D0 seg002:2E1D0 CeddyMods: ! far ! CODE XREF: sub_2605E+20P seg002:2E1D0 1D F4 58 90 mov:g.w r0, @TimAdvC_F458:16 seg002:2E1D4 1D 16 00 FF btst.w #15:16, @ModBits:16 seg002:2E1D8 26 0A bne TwoStepChk:8 seg002:2E1DA 1D 16 02 80 mov:g.w @RevLimit:16, r0 seg002:2E1DE 1D FD 00 90 mov:g.w r0, @Limit_FD00:16 seg002:2E1E2 11 19 prts seg002:2E1E4 ! --------------------------------------------------------------------------- seg002:2E1E4 seg002:2E1E4 TwoStepChk: ! CODE XREF: CeddyMods+8j seg002:2E1E4 1D 16 00 FE btst.w #14:16, @ModBits:16 seg002:2E1E8 27 38 beq KnockCEL:8 seg002:2E1EA 1D 16 04 80 mov:g.w @SpeedOff:16, r0 seg002:2E1EE 1D F2 FC 70 cmp:g.w @Speed_F2FC:16, r0 seg002:2E1F2 24 0A bcc TwoStepLimit:8 seg002:2E1F4 1D 16 02 80 mov:g.w @RevLimit:16, r0 seg002:2E1F8 1D FD 00 90 mov:g.w r0, @Limit_FD00:16 seg002:2E1FC 20 24 bra KnockCEL:8 seg002:2E1FE ! --------------------------------------------------------------------------- seg002:2E1FE seg002:2E1FE TwoStepLimit: ! CODE XREF: CeddyMods+22j seg002:2E1FE 1D 16 06 80 mov:g.w @TwoStepLimit:16, r0 seg002:2E202 1D FD 00 90 mov:g.w r0, @Limit_FD00:16 seg002:2E206 1D 16 00 FD btst.w #13:16, @ModBits:16 seg002:2E20A 27 16 beq KnockCEL:8 seg002:2E20C 1D 16 08 80 mov:g.w @AntiLagRPM:16, r0 seg002:2E210 00 nop seg002:2E211 00 nop seg002:2E212 00 nop seg002:2E213 00 nop seg002:2E214 1D F6 DA 70 cmp:g.w @TCAS0_F6DA:16, r0 seg002:2E218 25 08 bcs KnockCEL:8 seg002:2E21A 1D 16 0A 80 mov:g.w @IgnRetard:16, r0 seg002:2E21E 1D F4 58 90 mov:g.w r0, @TimAdvC_F458:16 seg002:2E222 seg002:2E222 KnockCEL: ! CODE XREF: CeddyMods+18j seg002:2E222 ! CeddyMods+2Cj ... seg002:2E222 1D 16 00 FC btst.w #12:16, @ModBits:16 seg002:2E226 27 14 beq MapSelect:8 seg002:2E228 1D 16 0C 80 mov:g.w @KnockCnt4CEL:16, r0 seg002:2E22C 1D F4 B6 70 cmp:g.w @KnockSum_F4B6:16, r0 seg002:2E230 24 06 bcc CELOff:8 seg002:2E232 1D F1 F8 C3 bset.w #3:16, @OutputBits_F1F8:16 seg002:2E236 20 04 bra MapSelect:8 seg002:2E238 ! --------------------------------------------------------------------------- seg002:2E238 seg002:2E238 CELOff: ! CODE XREF: CeddyMods+60j seg002:2E238 1D F1 F8 D3 bclr.w #3:16, @OutputBits_F1F8:16 seg002:2E23C seg002:2E23C MapSelect: ! CODE XREF: CeddyMods+56j seg002:2E23C ! CeddyMods+66j seg002:2E23C 1D 16 00 F7 btst.w #7:16, @ModBits:16 seg002:2E240 27 10 beq End:8 seg002:2E242 1D 16 00 F6 btst.w #6:16, @ModBits:16 seg002:2E246 26 06 bne Map1:8 seg002:2E248 1D F2 0A D5 bclr.w #5:16, @MapBits_F20A:16 seg002:2E24C 20 04 bra End:8 seg002:2E24E ! --------------------------------------------------------------------------- seg002:2E24E seg002:2E24E Map1: ! CODE XREF: CeddyMods+76j seg002:2E24E 1D F2 0A C5 bset.w #5:16, @MapBits_F20A:16 seg002:2E252 seg002:2E252 End: ! CODE XREF: CeddyMods+70j seg002:2E252 ! CeddyMods+7Cj seg002:2E252 11 19 prts seg002:2E252 ! End of function CeddyMods seg002:2E252 seg002:2E252 ! ---------------------------------------------------------------------------
Does anyone know if the OBD code will interfere you trying to light the CEL?
And if you are try to control timing, where is the best spot to do so?
If my code isn't clear, can add comments.
Anyone see any mistakes? Been bang my head off this for hours.
Last edited by Ceddy; Aug 25, 2009 at 01:39 AM.
#2
Evolved Member
Join Date: Mar 2008
Location: Lattitude 48.38°, Longitude 17.58°, Altitude 146m = Slovakia, for common dude
Posts: 730
Likes: 0
Received 2 Likes
on
2 Posts
I can speak only about KnockCEL as i have not been looking into implementation of the others.
Tephra implemented countdown variable to overcome your issue, so depending on your main loop frequency the value of countdown has to be reasonably big.
He is doing logical OR on CEL and KnockCEL, so if you have CEL it will be on until knock and blinking with knock, otherwise it will be off and blinking on CEL.
maybe tephra can send you code snippet in C, so you can compile it for H8.
Tephra implemented countdown variable to overcome your issue, so depending on your main loop frequency the value of countdown has to be reasonably big.
He is doing logical OR on CEL and KnockCEL, so if you have CEL it will be on until knock and blinking with knock, otherwise it will be off and blinking on CEL.
maybe tephra can send you code snippet in C, so you can compile it for H8.
Last edited by acamus; Aug 25, 2009 at 05:38 AM.
#3
Evolving Member
Thread Starter
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes
on
0 Posts
Thanks for the info, Acamus.
So Tephra's code replaces the OBD code CEL set/clr with or?
Tephra's countdown timer is for CEL blink duration and frequency, or does it serve another purpose?
I've been writing machine code by hand, I haven't found a good H8 assembler for Windows, all the Renesas tools seem geared toward C.
I can speak only about KnockCEL as i have not been looking into implementation of the others.
Tephra implemented countdown variable to overcome your issue, so depending on your main loop frequency the value of countdown has to be reasonably big.
He is doing logical OR on CEL and KnockCEL, so if you have CEL it will be on until knock and blinking with knock, otherwise it will be off and blinking on CEL.
Tephra implemented countdown variable to overcome your issue, so depending on your main loop frequency the value of countdown has to be reasonably big.
He is doing logical OR on CEL and KnockCEL, so if you have CEL it will be on until knock and blinking with knock, otherwise it will be off and blinking on CEL.
Tephra's countdown timer is for CEL blink duration and frequency, or does it serve another purpose?
I've been writing machine code by hand, I haven't found a good H8 assembler for Windows, all the Renesas tools seem geared toward C.
#4
Evolved Member
Join Date: Mar 2008
Location: Lattitude 48.38°, Longitude 17.58°, Altitude 146m = Slovakia, for common dude
Posts: 730
Likes: 0
Received 2 Likes
on
2 Posts
No He uses brand new variable (free memory location let us call it knock_cel) that is copy of variable used for setting output ports, (mut_9a IIRC), then the code where output ports are set uses knock_cel variable instead of mut_9a.
In his Knock_CEL routine pseudocode using C notation would look like
knock_cel = mut_9a;
if(<conditions>)
{
knock_cel |= 0x8;
}
else
{
knock_cel &= 0xFFF7;
}
<conditions> used in his KnockCEL routine are current_load>min_load, knock_CEL_enabled, knock_sum > knock_sum_min and countdown timers
true, simply duration and blinking.
All developers use some compiler, C is commonly used for micro-controllers.
I personally do it by hand also as the routines are so small that the time for setting the build environment is bigger than the time of looking up machine instructions.
In his Knock_CEL routine pseudocode using C notation would look like
knock_cel = mut_9a;
if(<conditions>)
{
knock_cel |= 0x8;
}
else
{
knock_cel &= 0xFFF7;
}
<conditions> used in his KnockCEL routine are current_load>min_load, knock_CEL_enabled, knock_sum > knock_sum_min and countdown timers
I personally do it by hand also as the routines are so small that the time for setting the build environment is bigger than the time of looking up machine instructions.
#5
Evolved Member
iTrader: (2)
The Renesis stuff is a combo of binutils (the assembler, linker, and some object tools), and GCC (language support; C, C++, etc), so while everything comes along for the ride, all you really need (assuming you don't like looking up instructions by hand in the datasheet) is "as". They've also got their own build of Eclipse, but I really think it's overkill for this kind of work.
I'm using KPIT's build of binutils for SH code (I'm not writing anything in C just yet), and the last time I looked, older versions of binutils supported H8/500 (the newer versions only seem to support H8/300, including the stuff KPIT redistributes), but I never got around to trying to get it built. Basically, H8/500 seems old and crufty enough that noone wants to support it anymore.
Have you thought of contacting Tom Dorris to see if he'd be willing to share what he's using for a dev environment for the '95 EEPROM ECUs? (Assuming they're H8; I don't know offhand.)
I'm using KPIT's build of binutils for SH code (I'm not writing anything in C just yet), and the last time I looked, older versions of binutils supported H8/500 (the newer versions only seem to support H8/300, including the stuff KPIT redistributes), but I never got around to trying to get it built. Basically, H8/500 seems old and crufty enough that noone wants to support it anymore.
Have you thought of contacting Tom Dorris to see if he'd be willing to share what he's using for a dev environment for the '95 EEPROM ECUs? (Assuming they're H8; I don't know offhand.)
#6
Evolving Member
Thread Starter
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes
on
0 Posts
The Renesis stuff is a combo of binutils (the assembler, linker, and some object tools), and GCC (language support; C, C++, etc), so while everything comes along for the ride, all you really need (assuming you don't like looking up instructions by hand in the datasheet) is "as". They've also got their own build of Eclipse, but I really think it's overkill for this kind of work.
I'm using KPIT's build of binutils for SH code (I'm not writing anything in C just yet), and the last time I looked, older versions of binutils supported H8/500 (the newer versions only seem to support H8/300, including the stuff KPIT redistributes), but I never got around to trying to get it built. Basically, H8/500 seems old and crufty enough that noone wants to support it anymore.
Have you thought of contacting Tom Dorris to see if he'd be willing to share what he's using for a dev environment for the '95 EEPROM ECUs? (Assuming they're H8; I don't know offhand.)
I'm using KPIT's build of binutils for SH code (I'm not writing anything in C just yet), and the last time I looked, older versions of binutils supported H8/500 (the newer versions only seem to support H8/300, including the stuff KPIT redistributes), but I never got around to trying to get it built. Basically, H8/500 seems old and crufty enough that noone wants to support it anymore.
Have you thought of contacting Tom Dorris to see if he'd be willing to share what he's using for a dev environment for the '95 EEPROM ECUs? (Assuming they're H8; I don't know offhand.)
Back when I was playing with the 95 code I built a cross-disassembler for the 68HC11, using cygwin. I was really proud of myself when I got it working, but it took me like a week of installing different version libraries to get everything to work together.
Coding by hand isn't that bad, I just search the existing code, any instruction combo you want, they used somewhere else.
It would be really nice if I could reassemble the whole ROM, then I wouldn't have to squeeze my code in the little unused spaces.
#7
Evolving Member
Thread Starter
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes
on
0 Posts
Thanks for the help Acamus, got my Knock CEL working.
I have it so it blinks on if you have no OBD CEL.
And blinks off if you have a OBD CEL.
The OBD code was interfering with the changes I made to the CEL bit before.
I have it so it blinks on if you have no OBD CEL.
And blinks off if you have a OBD CEL.
The OBD code was interfering with the changes I made to the CEL bit before.
Trending Topics
#8
Evolved Member
Join Date: Mar 2008
Location: Lattitude 48.38°, Longitude 17.58°, Altitude 146m = Slovakia, for common dude
Posts: 730
Likes: 0
Received 2 Likes
on
2 Posts
Glad to be of some help. Maybe you can port it for Evo5-6 guys and post it. I do not know how many are interested, but it would be nice to have KnockCEL for Evos5-6.
Last edited by acamus; Aug 26, 2009 at 09:52 PM.
#9
Evolving Member
Thread Starter
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes
on
0 Posts
I just put a pjsr where the stock code set, and where it clr the CEL bit.
And have it jump to my code.
I have no problem patching a ROM, if the Evo5/6 guys agree on a universal ROM.
Got the AntiLag working also, the timing variable I picked used a different scaling than the scaling used with the timing maps. It gets limited to -5 degrees, so I'll have to find a better spot to hook my code in.
And have it jump to my code.
I have no problem patching a ROM, if the Evo5/6 guys agree on a universal ROM.
Got the AntiLag working also, the timing variable I picked used a different scaling than the scaling used with the timing maps. It gets limited to -5 degrees, so I'll have to find a better spot to hook my code in.
Code:
seg002:2E254 ! =============== S U B R O U T I N E ======================================= seg002:2E254 seg002:2E254 seg002:2E254 sub_2E254: ! far ! CODE XREF: sub_28E4A+73P seg002:2E254 1D F1 F8 C3 bset.w #3:16, @OutPutBits_F1F8:16 seg002:2E258 1D FD 02 F0 btst.w #0:16, @BitFlags_FD02:16 seg002:2E25C 27 04 beq loc_2E262:8 seg002:2E25E 1D F1 F8 D3 bclr.w #3:16, @OutPutBits_F1F8:16 seg002:2E262 seg002:2E262 loc_2E262: ! CODE XREF: sub_2E254+8j seg002:2E262 11 19 prts seg002:2E262 ! End of function sub_2E254 seg002:2E262 seg002:2E264 seg002:2E264 ! =============== S U B R O U T I N E ======================================= seg002:2E264 seg002:2E264 seg002:2E264 sub_2E264: ! far ! CODE XREF: sub_28E4A:loc_28EC3P seg002:2E264 1D F1 F8 D3 bclr.w #3:16, @OutPutBits_F1F8:16 seg002:2E268 1D FD 02 F0 btst.w #0:16, @BitFlags_FD02:16 seg002:2E26C 27 04 beq loc_2E272:8 seg002:2E26E 1D F1 F8 C3 bset.w #3:16, @OutPutBits_F1F8:16 seg002:2E272 seg002:2E272 loc_2E272: ! CODE XREF: sub_2E264+8j seg002:2E272 11 19 prts seg002:2E272 ! End of function sub_2E264 seg002:2E272 seg002:2E272 ! ---------------------------------------------------------------------------
#12
Evolving Member
Thread Starter
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes
on
0 Posts
#13
Evolving Member
iTrader: (7)
Join Date: Sep 2006
Location: Northern VA
Posts: 146
Likes: 0
Received 0 Likes
on
0 Posts
The guys at ECM link/DSM link are working on flashable ECUs for us, but nothing as of yet.
I can put you in touch with one of the guys who has pioneered a lot of stuff on the VR4 ECUs. He's made $7 cables which can log any 94+ mitsu, I worked with him to get the Tactrix 1.3 cable to log the 94-95 VR4s with a simple $5 solution. He knows a ton of stuff about the ECUs, he has a bench rig set up to test different ECUs with, and is, well, a genius basically.
He may have already done some of what you're trying to do, or you may have done some of the things he is trying to do. PM me your email address and I'll ask him if he minds me giving you his so you guys can chat.
Thread
Thread Starter
Forum
Replies
Last Post
JM Auto Racing
EvoX 'For Sale' Electronics / Lighting / Audio
854
Nov 28, 2022 11:29 AM
MonacoGP
09+ Ralliart Engine/Turbo/Drivetrain
5
Apr 8, 2011 02:06 PM