DIY PROM Do It Yourself PROM chip burning help. No PROM begging. No PROMs for sale. No commercial exchange. Not a referral service.

$58 code strange behavior

Thread Tools
 
Search this Thread
 
Old Aug 9, 2005 | 12:08 AM
  #1  
junkcltr's Avatar
Thread Starter
Supreme Member
iTrader: (1)
 
Joined: Jan 2002
Posts: 4,432
Likes: 1
From: garage
Engine: 3xx ci tubo
Transmission: 4L60E & 4L80E
$58 code strange behavior

I have been commenting a $58 bin and found this strange piece of code. It is part of the initialization routine. It looks strange.

I think the CMPB 117 and CMPB 137 seem odd. It is comparing A/D values for the fuel pump to see if they are between 2.3 - 2.6 volts. I think GM was trying to see if the reference was within spec but made a mistake. Or am I reading it all wrong. I commented it and have posted it. It is interesting at the least.

Code:
LC820: 	LDS  	#$1FF     ;set stack pointer to end of RAM
	JSR  	LFAD3	  ;this calls the code below

LFB0F: 	LDAA 	#4		; reg_a = 0x04 (ADCCS_L signal)
 	TAB			; reg_b = reg_a
 	STD  	L0113		; MEM[0x0113] = 0x0404
 	JSR  	LFEFA		; call 0xFEFA (init devices)
 	ANDA 	#$03		; reg_a & 0x03
 	STAA 	L0110		; save the result to 0x0110
 	CLRA			; reg_a = 0, read channel_0
 	JSR  	LFF53		; call 0xFF53 (initilization A/D routine)
	;; reg_a contains the result from the A/D routine
        ;; *** WHICH WILL MOST LIKELY BE ZERO ALWAYS ---> SEE CODE BELOW ***
	;; *** At this point things are incorrect....and a LFB38: RTS will be done
	;;     because the LFF53 routine is most likely returning zero in reg_a
 	LDAA 	#$60
 	JSR  	LFF53
 	CMPA 	#160
 	BLS  	LFB38
 	LDAA 	#$10
 	JSR  	LFF53
 	CMPA 	#100
 	BCC  	LFB38
 	JSR  	LFF12
 	BCS  	LFB39
LFB38: 	RTS  



	;; **************************************************
	;; Initialization A/D read routine
	;; Purpose: Read A/D value from ADC chips
	;; INPUTS:  A/D channel to select in reg_a
	;; OUTPUTS: A/D result in reg_a
	;; *************************************************

LFF53: 	PSHB			; save reg_b on the stack
 	PSHX			; save reg_x on the stack
 	LDX  	#$4002		; select device
	BCLR 	0,X,#$08	;
 	JSR  	LFF37		; transfer data to device (result is stored in reg_a)
 	TAB			; save the return data to reg_b
	;; 
	;; read the A/D test channel and compare the initial
	;; channel that was read for values between 2.3 and 2.6 volts
	;; if not in that range, then set the returned value to 0 volts
 	LDAA 	#7		; reg_a = 7
LFF61: 	DECA			; decrement reg_a
 	BNE  	LFF61		; branch if zero (timeout)
 	LDAA 	#$B0		; reg_a = $B0 (A/D test channel)
 	JSR  	LFF37		; send the channel to device
 	BCS  	LFF76		; check if the carry bit is set
 	CMPB 	#117		; compare the A/D initial channel for 117d
 	BLS  	LFF76		; branch if it is less than 117d (2.3 volts)
 	CMPB 	#137		; compare the A/D initial channel for 137d
 	BHI  	LFF76		; branch if it is greater than 137d (2.6 volts)
 	CLC			; clear the carry bit
 	BRA  	LFF78		; branch
LFF76: 	CLRA			; reg_a = 0
 	SEC			; set the carry bit
LFF78: 	BSET 	0,X,#$08	; de-select device
 	PULX			; restore reg_x from the stack
 	PULB			; restore reg_b from the stack
 	RTS			; return to caller

Last edited by junkcltr; Aug 9, 2005 at 12:12 AM.
Reply
Old Aug 9, 2005 | 07:23 AM
  #2  
RBob's Avatar
Moderator
iTrader: (1)
 
Joined: Mar 2002
Posts: 18,432
Likes: 233
From: Chasing Electrons
Car: check
Engine: check
Transmission: check
The CMPB against #117 (2.29 V) and #137 (2.69 V) is checking the Vref of the ADC unit. This is from a read of the test channel. Which is what you have figured.

RBob.
Reply
Old Aug 9, 2005 | 08:47 AM
  #3  
junkcltr's Avatar
Thread Starter
Supreme Member
iTrader: (1)
 
Joined: Jan 2002
Posts: 4,432
Likes: 1
From: garage
Engine: 3xx ci tubo
Transmission: 4L60E & 4L80E
RBob, that is correct. It is checking Vref. But notice that it is CMPB not CMPA. Since it is CMPB, then it is comparing the A/D result from the channel that the calling function requested (not the A/D test channel). The TAB put the first A/D result in reg_b. The A/D test channel result was *never* put in reg_b.
Note that it does use the A/D test channel to see if the SPI bus did produce a response (the carry bit).

The A/D test channel result was never stored to reg_b, it is in reg)a, but GM was checking reg_b. It still doesn't make sense to me. I think they wanted to do a CMPA. Even if they did, the result from the first A/D channel is never stored back in reg_a to return to the calling Fxn.

On top of that, Channel_0 is the MAP2 pin which is pulled to ground via 51kohm resistor. So the result would always be close to zero.........but then calling function never uses the result anyway.

The real problem occurs when it checks the fuel pump voltage because the return A/D reading will most likely be forced to zero.

Please explain how the A/D test channel result is in fact being checked for 2.5V nominal. I just can't see it.....stared for over an hour at it.

Thanks,
J
Reply
Old Aug 9, 2005 | 09:20 AM
  #4  
RBob's Avatar
Moderator
iTrader: (1)
 
Joined: Mar 2002
Posts: 18,432
Likes: 233
From: Chasing Electrons
Car: check
Engine: check
Transmission: check
It is the order of AD conversion and AD data returns that is confusing. The loop at $FF37 is returning the data from the last requested conversion, not the current one.

Upon entry to $FF53 the first JSR to $FF37 starts the conversion on the desired channel and retrieves the data of the test channel (started from the previous call to the ADC routine). The second JSR to $FF37 starts the conversion on the test channel and retrieves the data for the desired channel.

The test channel data is then retrieved upon the next call for an ADC conversion.

RBob.

For completeness here is the code at $FF37:

Code:
LFF37: 		PSHX                    ;
LFF38: 		STAA    L4000           ;
LFF3B: 		LDX     #$4001          ;
LFF3E: 		BCLR    0,X,#$80        ;
LFF41: 		LDAA    #22             ;
LFF43: 		CLC                     ;
LFF44: 		BRSET 0,X,#$80,LFF4E    ;
LFF48: 		DECA                    ;
LFF49: 		BNE     LFF44           ;
LFF4B: 		SEC                     ;
LFF4C: 		BRA     LFF51           ;
LFF4E: 		LDAA    L4000           ;
LFF51: 		PULX                    ;
LFF52: 		RTS                     ;
Reply
Old Aug 9, 2005 | 09:39 AM
  #5  
junkcltr's Avatar
Thread Starter
Supreme Member
iTrader: (1)
 
Joined: Jan 2002
Posts: 4,432
Likes: 1
From: garage
Engine: 3xx ci tubo
Transmission: 4L60E & 4L80E
The loop at $FF37 is returning the data from the last requested conversion, not the current one.
You are good. I wasn't even thinking about that. It is obvious once you said it. That is why the result from the first A/D read is ignored. And no A/Ds exist that convert in zero time, much less converters made in the early 1990s.
Thank you. Now I can continue on commenting this evening.

Last edited by junkcltr; Aug 9, 2005 at 10:08 AM.
Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
Fanatic1074
Tech / General Engine
45
Oct 3, 2022 05:57 AM
Falcon50
DFI and ECM
81
Aug 22, 2020 03:26 PM
RS Reaper
Electronics
4
Oct 17, 2018 07:52 PM
racereese
Tech / General Engine
14
Oct 3, 2015 03:46 PM
Luigytico09
TPI
0
Oct 1, 2015 08:46 AM




All times are GMT -5. The time now is 04:38 PM.