Notices
ECU Flash

New Code Help. (Code Gurus Needed)

Thread Tools
 
Search this Thread
 
Old Aug 24, 2009, 09:00 PM
  #1  
Evolving Member
Thread Starter
 
Ceddy's Avatar
 
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.

New Code Help. (Code Gurus Needed)-ceddymods.jpg


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
All references to the normal RevLimit were replaced with the memory location FD00.


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             ! ---------------------------------------------------------------------------
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.

Last edited by Ceddy; Aug 25, 2009 at 01:39 AM.
Old Aug 25, 2009, 05:31 AM
  #2  
Evolved Member
 
acamus's Avatar
 
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.

Last edited by acamus; Aug 25, 2009 at 05:38 AM.
Old Aug 25, 2009, 06:40 PM
  #3  
Evolving Member
Thread Starter
 
Ceddy's Avatar
 
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes on 0 Posts
Thanks for the info, Acamus.

Originally Posted by acamus
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.
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?


Originally Posted by acamus
maybe tephra can send you code snippet in C, so you can compile it for H8.
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.
Old Aug 25, 2009, 09:45 PM
  #4  
Evolved Member
 
acamus's Avatar
 
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
Post

Originally Posted by Ceddy
So Tephra's code replaces the OBD code CEL set/clr with or?
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

Originally Posted by Ceddy
Tephra's countdown timer is for CEL blink duration and frequency, or does it serve another purpose?
true, simply duration and blinking.

Originally Posted by Ceddy
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.
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.
Old Aug 26, 2009, 10:35 AM
  #5  
Evolved Member
iTrader: (2)
 
logic's Avatar
 
Join Date: Apr 2003
Location: Berkeley, CA
Posts: 1,022
Likes: 0
Received 6 Likes on 5 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.)
Old Aug 26, 2009, 11:10 AM
  #6  
Evolving Member
Thread Starter
 
Ceddy's Avatar
 
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by logic
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.)
The 95 ECUs use the Motorola 68HC11, they didn't start using the Hitachi/Renesis cpu until 97, only 98-99 are flashable.

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.
Old Aug 26, 2009, 01:34 PM
  #7  
Evolving Member
Thread Starter
 
Ceddy's Avatar
 
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.
Old Aug 26, 2009, 09:39 PM
  #8  
Evolved Member
 
acamus's Avatar
 
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
Originally Posted by Ceddy
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.
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.
Old Aug 26, 2009, 10:45 PM
  #9  
Evolving Member
Thread Starter
 
Ceddy's Avatar
 
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.

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             ! ---------------------------------------------------------------------------
Old Aug 27, 2009, 02:54 AM
  #10  
EvoM Guru
iTrader: (6)
 
tephra's Avatar
 
Join Date: Feb 2007
Location: Melbourne, Australia
Posts: 9,486
Received 66 Likes on 42 Posts
lol i'm using ASM as well dude... no C here

my earlier versions of tephramod used to replace the variable for doing the knockcel... now I just xor the current variable...
Old Aug 28, 2009, 03:12 PM
  #11  
Evolving Member
iTrader: (7)
 
jba3's Avatar
 
Join Date: Sep 2006
Location: Northern VA
Posts: 146
Likes: 0
Received 0 Likes on 0 Posts
If this works on the 98/99 VR4 there could be a small market for it, since VR4s can swap ECUs pretty easy and we have nothing but piggyback or AEM as an option.
Old Aug 28, 2009, 04:02 PM
  #12  
Evolving Member
Thread Starter
 
Ceddy's Avatar
 
Join Date: Apr 2008
Location: Reading, PA
Posts: 265
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by jba3
If this works on the 98/99 VR4 there could be a small market for it, since VR4s can swap ECUs pretty easy and we have nothing but piggyback or AEM as an option.
3000GT VR4s? I believe the 98 and 99s are flashable with the OP 2.0 cable.
Old Aug 29, 2009, 04:49 PM
  #13  
Evolving Member
iTrader: (7)
 
jba3's Avatar
 
Join Date: Sep 2006
Location: Northern VA
Posts: 146
Likes: 0
Received 0 Likes on 0 Posts
Originally Posted by Ceddy
3000GT VR4s? I believe the 98 and 99s are flashable with the OP 2.0 cable.
Indeed they are. However, there's no public release of the data struction of the ROM, nor are there any mods or patches for it. We're only able to play with timing, fuel trims, and other things that came stock with the car. Adding NLTS, 2 step, CELflash, and other things hasn't been done before. We have to go AEM or GReddy Emanage to do so, and those are $800-$2000 "solutions".

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.
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
JM Auto Racing
EvoX 'For Sale' Electronics / Lighting / Audio
854
Nov 28, 2022 11:29 AM
Nsk
ECU Flash
22
Jul 11, 2020 02:01 AM
kassir
ECU Flash
3
Oct 30, 2011 04:34 PM
MonacoGP
09+ Ralliart Engine/Turbo/Drivetrain
5
Apr 8, 2011 02:06 PM
napado
Evo X Engine Management / Tuning Forums
13
Mar 31, 2010 01:49 AM



Quick Reply: New Code Help. (Code Gurus Needed)



All times are GMT -7. The time now is 03:55 AM.