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

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
02/14/05 19:51
Modified:
  02/14/05 20:04

Read: times


 
#87427 - acdu812 and spi. program question
simple problem for you all but not for me, just getting started in 8052 programing. the dac is a 12 ch dac.
I want to send serial data to the adcu812 then send that data along with the ad8802 dac address for a dac ch then send the data from the pc. to the dac. the code below is cut and paste from several examples i am studing. I don't know what to do in respect to adding the dac chip address and then the data. I think it will will need to be shifted out. but how?.
can any one give me some pointers? or even how to ask the question better. I am tring to learn. the asm is asprie, it came with the adcu812 e-val bd. thanks. ron.
;***************************************************
;
; Author : Ron Buchwald
;
; Date : 14 feb 2005
;
; File : serial to spi interface
;
; Hardware : ADuC812 - AD8802 DAC.
;
; Description : Blinks LED, Recives serial data
; : sends data out spi to DAC.
;
;
;******************************************************

$MOD812 ; use 8052 predefined symbols

LED EQU P3.4 ; P3.4 is red LED on eval board
SS EQU P3.5 ; P3.5 drives slave device's SS pin

DSEG
ORG 0060h

; INPUT: DS 1 ; data byte received by SPI
OUTPUT: DS 1 ;data byte to send by SPI

;_______________________________________________
; MAIN PROGRAM
CSEG

ORG 0000h
JMP MAIN ; jump to main program

ORG 003Bh ; (.................... SPI ISR)

SETB SS l ;slave's SS pin high

RETI


MAIN:
; configure the UART ADuC812
MOV SCON,#52h ; configure UART for 9600baud..
MOV TMOD,#20h ; ..assuming 11.0592MHz crystal
MOV TH1,#-3
SETB TR1 ; ok this works

; CONFIGURE SPI...

MOV SPICON,#037h ; configure SPI port for:
; Fosc/64, CPHA=1, CPOL=0, master
MOV IE2,#1 ; enable SPI interrupt
; OK THIS WORKS


JNB RI,$ ; Recive serial data
MOV A,SBUF ; Store data in acc
MOV SPIDAT,SBUF


BLINK: CPL LED ; flash (complement) the red LED
CALL DELAY ; call software delay
;JMP BLINK ; repeat indefinately
;MOV OUTPUT,A ;? SEND A TO OUTPUT???
CLR TI ; CLEAR TI FLAG
MOV SBUF,A ; SEND ACC DATA OUT SERIAL BUFF FOR ECHO TEST
JNB TI,$ ; WAIT TILL DATA SENT
CALL SENDSPI
JMP MAIN ; REPEAT ALL



;.....................................................
; SPI SEND CODE?????

SENDSPI:
; sends the value in ACC out the SPI port. also
; receives simultaneously into SPIDAT. SPI interrupt
; is triggered when transfer is complete.

CLR SS ; must pull slave's SS pin low first
MOV SPIDAT,OUTPUT ; trigger data transfer
SETB SS
RET



;_________________________________________________
;SUBROUTINES

DELAY: ; delay 100ms

MOV R7,#200 ; 200 * 500us = 100ms
DLY1: MOV R6,#229 ; 229 * 2.17us = 500us
DJNZ R6,$ ; sit here for 500us
DJNZ R7,DLY1 ; repeat 200 times (100ms delay)

RET

;_________________________________________________________

END


List of 7 messages in thread
TopicAuthorDate
acdu812 and spi. program question            01/01/70 00:00      
   Try            01/01/70 00:00      
   CS in SPI            01/01/70 00:00      
   thanks.. but....            01/01/70 00:00      
   Sorry            01/01/70 00:00      
   The problem may be....            01/01/70 00:00      
      re:SPI on ADuC812            01/01/70 00:00      

Back to Subject List