Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
07/09/02 06:17
Read: times


 
#25503 - the ADC (lots of source code ahead)
I have written this program, but when I try to assemble it, the assembler locks up saying "First Pass" and it hangs there. The timing of the ADC is as follows. Send an 8 bit control byte (im using the one for channel 0), send 8 clock bits of 0 to allow the chip to do the conversion, and send 8 bits of 0s while recieving the answer in another byte. You may have to copy and paste this code into notepad to get it to align right. (And I thought I actually had
it!)

*******************

$mod51

; MAX1112 Control Bytes
; Single mode, unipolar, external clock
; Channel 0 : 10001111
; Channel 1 : 11001111
; Channel 2 : 10011111
; Channel 3 : 11011111
; Channel 4 : 10101111
; Channel 5 : 11101111
; Channel 6 : 10111111
; Channel 7 : 11111111

; P1.4 connects to DIN
; P1.0 connects to SLK
; P1.5 connects to DOUT

org 00h


Sensor_0_Initialize:

MOV A, #10001111b ; Insert the byte value to send here.
MOV R1, #8 ; Set register R1 to 8 counts. (8 bits)


Clock_ADC_Out:

RRC A ; Rotate ACC
MOV P1.4, C
SETB P1.0
CLR P1.0
DJNZ R1, Clock_ADC_Out

CLR P1.4 ; Set P1.4 low for the rest of the conversion.
MOV R1, #8 ; Set register R1 to 8 counts. (8 bits)

Clock_8_Bits:

MOV P1.4, C
SETB P1.0
CLR P1.0
DJNZ R1, Clock_8_Bits

MOV R1, #8

Clock_ADC_In:

MOV C, P1.4
MOV A, C
RLC A
SETB P1.0
CLR P1.0
DJNZ R1, Clock_ADC_In

MOV R2, A ; Place final recieved byte of information in R2.


JNB R2, Light2On ; If R2 is 0, light 1 goes on.
If R2 is higher than 0 (analog voltage higher than 0, other light is on.)

Light1on:

SETB P1.7
CLR P1.6

AJMP Sensor_0_Initialization ; Restart and do it all again!


Light2on:

CLR P1.7
SETB P1.6

AJMP Sensor_0_Initialization ; Restart and do it all again!


End



List of 16 messages in thread
TopicAuthorDate
the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      
RE: the ADC (lots of source code ahead)            01/01/70 00:00      

Back to Subject List