This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC1220, reading process, OCR,FCR, DIR

Other Parts Discussed in Thread: DAC1220

Hi,

I post a few weeks ago another problem that I had with the DAC1220, and finally I understand how it works, but I now have problems with the read operations, I try to read the DIR, after I sent a code to the DAC, but I couldn't, I used exactly the same procedure like in a write operation, because in the datasheet, in the figure 10, the SDIO line have the same procedure, I mean the figure where is t10,t9 and t15. in page 10 of the DAC1220 datasheet. So what can be the problem?, like I said, I used the same set of instructions like in a write operation, except that I configurated my microcontroller like an input, in the SPI protocol, I used the ATmega16 from atmel corporation and a LCD to see the values in the OCR and FCR. Please I need a explanation.

And one more thing, I want to read the OCR, FCR after the self calibration, so this way I can know the value codes which the DAC1220 fill up these two registers, and later I can make a manual calibration making a write operation in the OCR and FCR, all this, because I want to know if after this, the DAC have the same initial value, for example let's say after the self calibration the OCR have $4565FA and the FCR have $F2CD34, and with the code for 15 mv and a Vref of 2.5 v, I obtain 13.4 mv, and after other self calibration the OCR have $4565FF and the FCR have $F2CD4F, and with the code for 15 mv, I obtain 14.6 mv. So when I turn off my device, controlled by the microcontroller, and I turn on again, and I sent to the OCR $4565FF and to the FCR $F2CD4F, I will obtain again 14.6 mv???. Answer me these doubts soon, please. I'm hurry, and I need the information. Thanks again to TI. I hope you can help me.

Regards 

  • Hi again, here I send a part of my code in assembly for the communication with the DAC, can you check the subroutines for the reading procedure, please?. The RET is for return, I mean the exit of the subroutine. I indicated in red, the fragment of the code for the communication with one of the DACs, compare the write process subroutine and the read  process subroutine, the times and all the comments are showed after a ';'.

    In the figure 11, I don't understand the times t11 and t12, this can be the problem or not?.

     

     I hope you can help me with this, thanks again. Bye




    ;THIS IS THE CONFIGURATION FOR THE ISP
    CONFIGURA_SPI:

    PUSH R17
    LDI R17, (1<<DDB5)| (1<<DDB7)
    OUT DDRB,R17
    SBI DDRB,PB4
    ;Habilitar SPI, MASTER, FIJAR VELOCIDAD RELOJ FCK/16
    LDI R17,(1<<SPE)|(0<<DORD)|(1<<MSTR)|(1<<CPHA)|(1<<SPR0) ; 7 6 5 4 3 2 1 0
    ;SPCR: /SPIE/SPE/DORD/MSTR/CPOL/CPHA/SPR1/SPRO/
    OUT SPCR,R17; SPSR: SPIF WCOL - - - - - SPI2X/ [SPI2X SPR1 SPR0]---> CONTROLAN FRECUENCIA DE SCK
    LDI R17,(0<<SPI2X)
    OUT SPSR,R17
    POP R17
    ret






    ;---- SUBRUTINAS DEL spi----------------

    ;SUBRUTINA DE TRANSMISION

    SPI_MASTER_TRANSMISION:
    OUT SPDR,R16
    WAIT_TRANSMISION:
    SBIS SPSR,SPIF
    RJMP WAIT_TRANSMISION
    RET


    ;RECEPTION SUBROUTINE

    SPI_MASTER_RECEPTION:
    SBIS SPSR,SPIF
    RJMP SPI_MASTER_RECEPTION
    IN R16,SPDR
    RET



    ;THIS SUBROUTINE SENDS THE BYTES FOR THE CMR, TO ENTER THE NORMAL MODE, FOR THE COMMUNICATION WITH DAC1


    BEGIN_COMUNI_DAC1:
    ;COMENZAMOS CON LA CONFIGURACION Y EL ENVIO DE DATOS AL DAC
    ;INSR: R/W/MB1/MB0/0/A3/A2/A1/A0
    PUSH R16
    CBI PORTC,PC6;ACTIVAMOS LA COMUNICACION CON EL DAC 1
    nop
    nop
    LDI R16,0B00100100
    RCALL RETAR_PEQUE;t10
    RCALL SPI_MASTER_TRANSMISION
    RCALL RETAR_PEQUE;t9
    LDI R16,0B01100000;BYTE 1 DEL CMR
    RCALL SPI_MASTER_TRANSMISION
    LDI R16,0B10110000;BYTE 0 DEL CMR
    RCALL SPI_MASTER_TRANSMISION
    RCALL RETAR_PEQUE
    rcall NUEVO_INSR_DATOS_DAC1
    SBI PORTC,PC6;DESACTIVAMOS LA COMUNICACION CON EL DAC 1
    nop
    nop
    RCALL RETAR_PEQUE
    POP R16
    RET


    ;THIS SUBROUTINE SENDS THE BYTES FOR THE CMR, FOR THE COMMUNICATION WITH DAC2


    BEGIN_COMUNI_DAC2:
    ;COMENZAMOS CON LA CONFIGURACION Y EL ENVIO DE DATOS AL DAC
    ;INSR: R/W/MB1/MB0/0/A3/A2/A1/A0
    PUSH R16
    CBI PORTC,PC7;ACTIVAMOS LA COMUNICACION CON EL DAC 2
    nop
    nop
    LDI R16,0B00100100
    RCALL RETAR_PEQUE;t10
    RCALL SPI_MASTER_TRANSMISION
    RCALL RETAR_PEQUE;t9
    LDI R16,0B01100000;BYTE 1 DEL CMR
    RCALL SPI_MASTER_TRANSMISION
    LDI R16,0B10110000;BYTE 0 DEL CMR
    RCALL SPI_MASTER_TRANSMISION
    RCALL RETAR_PEQUE
    rcall NUEVO_INSR_DATOS_DAC2
    nop
    nop
    SBI PORTC,PC7;DESACTIVAMOS LA COMUNICACION CON EL DAC 2
    RCALL RETAR_PEQUE
    POP R16
    RET



    ;THIS SUBROUTINE SENDS THE BYTES FOR DIR TO DAC1, USING DATOS_AL_DAC

    NUEVO_INSR_DATOS_DAC1:
    PUSH R16
    SBI PORTC,PC6;DESACTIVAMOS LA COMUNICACION CON EL DAC
    RCALL RETAR_PEQUE;t15
    CBI PORTC,PC6;ACTIVAMOS LA COMUNICACION CON EL DAC
    nop
    nop
    RCALL RETAR_PEQUE;t10
    RCALL DATOS_AL_DAC
    nop
    nop
    RCALL RETAR_PEQUE;t15
    POP R16
    RET


    ;THIS SUBROUTINE SENDS THE BYTES FOR DIR TO DAC2, USING DATOS_AL_DAC


    NUEVO_INSR_DATOS_DAC2:
    PUSH R16
    SBI PORTC,PC7;DESACTIVAMOS LA COMUNICACION CON EL DAC 2
    RCALL RETAR_PEQUE;t15
    CBI PORTC,PC7;ACTIVAMOS LA COMUNICACION CON EL DAC 2
    nop
    nop
    RCALL RETAR_PEQUE;t10
    RCALL DATOS_AL_DAC
    nop
    nop
    RCALL RETAR_PEQUE;t15
    POP R16

    RET


    ;THIS SUBROUTINE HAVE THE INSR AND THE 3 BYTES OF THE DIR, AND SEND THESE FOUR BYTES IN A WRITE PROCESS


    DATOS_AL_DAC:
    PUSH R16
    LDI R16,0B01000000
    RCALL SPI_MASTER_TRANSMISION
    RCALL RETAR_PEQUE
    MOV R16,R1
    RCALL SPI_MASTER_TRANSMISION
    MOV R16,R2
    RCALL SPI_MASTER_TRANSMISION
    MOV R16,R3
    RCALL SPI_MASTER_TRANSMISION
    POP R16
    RET


    ;DELAY SUBROUTINE

    RETAR_PEQUE:;30 us
    push R16 ; 2 ciclos
    push R17 ; 2 ciclos
    clr R17 ; 1 ciclo
    LAZO_RETAR_PEQUE:
    inc R17 ; 1 ciclo
    CPI R17,10
    brne LAZO_RETAR_PEQUE ; 2 ciclos
    pop R17 ; 2 ciclos
    pop R16 ; 2 ciclos

    ret ; 5 ciclos


    ;HERE BEGINS THE READING PROCESS
    ;THIS SUBROUTINE IS FOR READING THE DIR REGISTER OF THE DAC 1

    Obtener_OCR_FCR_DAC1:

    PUSH R16
    PUSH R17
    LDI XH,HIGH(STORE)
    LDI XL,LOW(STORE)
    CBI PORTC,PC6;ACTIVAMOS LA COMUNICACION CON EL DAC 1
     nop
    nop
    LDI R16,0B11001000
    RCALL RETAR_PEQUE;t10
    RCALL SPI_MASTER_TRANSMISION
    RCALL RETAR_PEQUE;t9
    RCALL SPI_MASTER_RECEPTION
    ST X+,R16
    RCALL SPI_MASTER_RECEPTION
    ST X+,R16
    RCALL SPI_MASTER_RECEPTION
    ST X+,R16
    RCALL RETAR_PEQUE
    SBI PORTC,PC6;DESACTIVAMOS LA COMUNICACION CON EL DAC 1
    nop
    nop
    ;esta parte es para el FCR
    RCALL RETAR_PEQUE;t15
    CBI PORTC,PC6
    RCALL RETAR_PEQUE;t10
    LDI R16,0B11001100
    RCALL SPI_MASTER_TRANSMISION
    RCALL RETAR_PEQUE;t9
    RCALL SPI_MASTER_RECEPTION
    ST X+,R16
    RCALL SPI_MASTER_RECEPTION
    ST X+,R16
    RCALL SPI_MASTER_RECEPTION
    ST X+,R16
    RCALL RETAR_PEQUE
    SBI PORTC,PC6;DESACTIVAMOS LA COMUNICACION CON EL DAC 1
    RCALL RETAR_PEQUE
    POP R17
    POP R16
    RET



    ;THIS SUBROUTINE ALLOWS TO SHOW THE CONTENT OF THE OCR AND FCR IN A LCD MODULE


    Mostrar_OCR_FCR_DAC1:
    PUSH R16
    PUSH R17
    rcall ins_limpiar_display
    LDI R16,0
    LDI XH,HIGH(STORE)
    LDI XL,LOW(STORE)
    escribe_otro:
    rcall CheckBF
    LD R17,X+
    rcall WriteDR
    inc R16
    cpi R16,3 ;Muestra del texto Mensaje sólo 12 caracteres
    breq terminar
    rjmp escribe_otro

    terminar:
    PUSH R17
    POP R16
    ret  

  • Daniel,

    It is a little hard for me to follow your code, though it appears to be ok.  The DAC1220 interface for the serial pin is bi-directional, so when you are writing and reading from the same pin a minimum of time (t9) is required between the last SCLK of the write and the first SCLK of the read.  You probably want to add a weak pull-up resistor (100k) on the SDIO line so that it doesn't float when transitioning between the two operating states.

    The best thing you could do is get some oscilloscope shots of the the communication and post them here.  We could then check to make sure the timing for the communication and the command data word to the DAC1220 for reading out the data is correct.

    Best regards,

    Bob B