A/D read SR
A/D read SR
Code:
* ADREAD.SRC * * Read serial A/D * * Call with: * Ch num in A reg * * Return with: * A/D result in A reg * or ) if A/D or serial fails * * TYPE $8D, ECM P/N 1227730 ******************************************************* LF0D2: PSHX LDX #$4000 ; GM Regester SEI ; HOLD INTERUPTS BCLR 2,X,#$08 ; SELECT SERIAL A/D CHIP STAA 0,X ; CH TO DON IN SSR BCLR 1,X,#$80 ; CLR b7, SEND CH NUM ; ; 8 SCLK's delay ; PSHB MUL MUL MUL PULB LDAA 0,X ; LD TEST CH RESULT FM SSR STAA $01AE ; SAVE RESULT ; ; delay 64 cycles ; PSHB MUL MUL MUL MUL MUL NOP PULB ;---------------------------- ; READ A/D TEST CH ; ;---------------------------- LDAA #$B0 ; SET A/D CH 11 FOR TEST STAA 0,X ; WR TO SSR BCLR 1,X,#$80 ; CLR b7, SEND CH NUM ; ; delay ; PSHB MUL MUL MUL PULB LDAA 0,X ; GET RESULT BSET 2,X,#$08 ; DISABLE SAD CLI ; INT'S BACK ON PULX RTS ***************************************************
It looks like the result is stored at $4000 and $01AE after the first 8 delays.
Then another 64 cycles and ch 11 is read and stored at $4000 again. Which wipes out the first result.
Or is this a 2 step process and the first result is an intermediate result?
Just how does this routine work?
Last edited by Z69; Mar 6, 2005 at 04:06 PM.
Moderator
iTrader: (1)
Joined: Mar 2002
Posts: 18,432
Likes: 233
From: Chasing Electrons
Car: check
Engine: check
Transmission: check
This routine is easily confusing. The best way to look at it is that on entry Reg A contains the channel to be converted. On exit, Reg A contains that channels data.
The reason it is confusing is the order of data conversions.
The new desired channel is set and the conversion started. After a delay the last conversion data is retrieved. This data is the test channel, and is previous to the current acquisition data channel.
Once the test channel data is retrieved another delay occurs. At the end of that delay the desired channel data is retrieved. And the test channel conversion is started.
Now, the routine doesn't wait for the test channel, it returns with the desired channel data. The test channel data value is retrieved the next time this routine is called.
RBob.
The reason it is confusing is the order of data conversions.
The new desired channel is set and the conversion started. After a delay the last conversion data is retrieved. This data is the test channel, and is previous to the current acquisition data channel.
Once the test channel data is retrieved another delay occurs. At the end of that delay the desired channel data is retrieved. And the test channel conversion is started.
Now, the routine doesn't wait for the test channel, it returns with the desired channel data. The test channel data value is retrieved the next time this routine is called.
RBob.
Originally posted by Z69
Thanks Rbob
Is that because the adc chip needs something to push the old data out so to speak or trigger a send...?
Thanks Rbob
Is that because the adc chip needs something to push the old data out so to speak or trigger a send...?
Thread
Thread Starter
Forum
Replies
Last Post




