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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/19/05 14:29
Read: times


 
#87961 - What do you know it's working but one...
Responding to: ???'s previous message
Well i got it to work. the pc visual basic pgm now controls the 812 and the 12 ch dac...but in the code below...if I put the config serial port out side the main loop it does not recive the data. I read that you need to config the port only once. any one see what is wrong. it does work however the way it is now. Ron.

<PRE>

;................................................
;NEW CODE WITHOUT CHKSUM
;2/19/05
;ADCU812 AND AD8802 12 CH DAC.
;................................................

$MOD812
LOOPCOUNT DATA 44H ;COUNT LOOPS
LED EQU P3.4 ;IS LED
FLAG BIT 00H ; define Flag variable


CSEG ; Defines the following as a segment of code

ORG 0000H ; Load Code at '00H'

JMP MAINLOOP

;======================================================================

ORG 0003h

; FOR TEST ONLY
INC R2 ; Increment DAC VALUE
RETI ; Return from Interrupt
;====================================================================

MAINLOOP:

; configure the UART ADuC812
; MUST BE IN MAIN LOOP OR DOES NOT WORK WHY?????????

MOV SCON,#52h ; configure UART for 9600baud..
MOV TMOD,#20h ; ..assuming 11.0592MHz crystal
MOV TH1,#-3
SETB TR1 ; ok this works
SETB IT0 ; INT0 edge triggered
SETB EA ; enable inturrupts
SETB EX0 ; enable INT0
; OK CAN INTR.
CLR FLAG ; Clear Bit defined as FLAG


;... THIS THE RIGHT PLACE FOR THIS.....................

JNB RI,$ ; Recive serial data
MOV R0,SBUF ; Store data in R0 AS ADDR
CLR RI

JNB RI,$ ; Recive serial data
MOV R1,SBUF ; Store data in R1 AS VALUE
CLR RI
;.........................................................

;Do Check SUM
; AJMP MAINLOOP ; Start over if bad

;CSUM GOOD
; move address and data into R0,R1
ACALL LD_8802
; repeat for all DACs

JMP MAINLOOP
LD_8802:

ORL P2,#11110000B ;SET CLK,CS,SHDN HIGH
CLR P2.5 ;SET CHIP SELECT LOW
MOV LOOPCOUNT,#4 ;ADDRESS IS 4 BITS
MOV A,R0 ;GET DAC ADDRESS
RR A ;ROTATE THE DAC
RR A ;ADDRESS TO MOST
RR A ;SIGNIFCANT BIT (MSB)
RR A
ACALL SEND_SERIAL ;SEND THE ADDRESS
MOV LOOPCOUNT,#8 ;DO 8 BIT OF DATA
MOV A,R1
ACALL SEND_SERIAL ;SEND THE DATA
SETB P2.5 ;SET CS HIGH
RET ;DONE


SEND_SERIAL: RLC A ;MOVE NEXT BIT TO CARRY
CPL LED ;BLINK LED
MOV P2.7,C ;MOVE DATA TO SDI
CLR P2.6 ;PULSE THE
SETB P2.6 ;CLK INPUT
DJNZ LOOPCOUNT,SEND_SERIAL ;LOOP IF NOT DONE
RET ;DONE
END
<pre/>

List of 12 messages in thread
TopicAuthorDate
ADcu812 question fixed (: now can......            01/01/70 00:00      
   OK            01/01/70 00:00      
      thank you neil..but?            01/01/70 00:00      
         Checksum            01/01/70 00:00      
         Your Origional code            01/01/70 00:00      
   Try as i might......now it does not work            01/01/70 00:00      
      OK            01/01/70 00:00      
         answer to neil            01/01/70 00:00      
            OK            01/01/70 00:00      
   What do you know it's working but one...            01/01/70 00:00      
      Not Sure            01/01/70 00:00      
         THANK YOU NEIL            01/01/70 00:00      

Back to Subject List