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.

用SSI和DAC8534实现DAC转换问题

Other Parts Discussed in Thread: DAC8534

如果用DAC8534实现DAC转换该怎么设置?

用SSIConfigSetExpClk()函数只能设置发送数据宽度为4~16,而DAC8534为16位DAC转换芯片,每次发送24为前面八位为控制位,决定从ABCD哪个通道输出。要怎么设置才能实现SSI与DAC8534之间的数据传输呢?

  • 如果是24bits,可以用8位宽度,FIFO深度设为3就好,8*3 = 24 

    每次发送24为前面八位为控制位,决定从ABCD哪个通道输出。要怎么设置才能实现SSI与DAC8534之间的数据传输呢?

    这个问题是指什么意思?没看明白。

  • 用哪个库函数进行设置呢?设置完比如说前8位固定0xA0,要发送一个不停变化的16位的数,用变量Num代替。该怎么发送呢?

  • void
    SSIDataPut(uint32_t ui32Base,
    uint32_t ui32Data)

    用这个函数发送数据就好了。用num代替ui32Data就好了。注意手册上的这个说明

    The upper 32 - N bits of ui32Data are discarded by the hardware, where N is the data width as
    configured by SSIConfigSetExpClk(). For example, if the interface is configured for 8-bit data
    width, the upper 24 bits of ui32Data are discarded.

    如果发送的是8位数据的话,有24位是无效的。

  • Num是个16位的啊,怎么能那样发呢?你的意思是不是用SSIDataPut()发送三次,第一次发送前面八位控制位,第二次发送Num的高八位,第三次发送Num的低八位

    也就是:

    SSIDataPut(SSI0_BASE,0xA0);

    SSIDataPut(SSI0_BASE,(0xFF00&Num)>>4);

    SSIDataPut(SSI0_BASE,0x00FF&Num);

    是这样吗?这样行的通吗?

  • 理论是可以的,具体需要测试。你为什么不把这三个,组合为一个u32的数据呢。

  • SSIConfigSetExpClk()函数中数据帧长度只能是4~16位,SSIConfigSetExpClk()函数中数据帧长度确定了,SSIDataPut()发送的数据的有效位数就确定了,如果组合成U32怎么发送呢?

  • 我的意思是DAC8534数据输入寄存器的格式是24位的,D23和D22位为地址选择,D21和D20位为输出通道加载位,D19不用管,D18和D17位为信号输出通道选择位,D16位为电源下拉模式选择标志位。后16位为用于DAC转换的数据位。SSIConfigSetExpClk()能发送的数据帧长度范围为4~16,如果要用DAC8534对一个16位的变量实现DAC转换,那么DAC8534数据输入寄存器的前面8位怎么写进去呢?

  •    // Read any residual data from the SSI port.  This makes sure the receive
        // FIFOs are empty, so we don't read any unwanted junk.  This is done here
        // because the SPI SSI mode is full-duplex, which allows you to send and
        // receive at the same time.  The SSIDataGetNonBlocking function returns
        // "true" when data was returned, and "false" when no data was returned.
        // The "non-blocking" function checks if there is any data in the receive
        // FIFO and does not "hang" if there isn't.
        //
        while(SSIDataGetNonBlocking(SSI0_BASE, &pui32DataRx[0]))
        {
        }
    
        //
        // Initialize the data to send.
        //
        pui32DataTx[0] = 's';
        pui32DataTx[1] = 'p';
        pui32DataTx[2] = 'i';
    
        //
        // Display indication that the SSI is transmitting data.
        //
        UARTprintf("Sent:\n  ");
    
        //
        // Send 3 bytes of data.
        //
        for(ui32Index = 0; ui32Index < NUM_SSI_DATA; ui32Index++)
        {
            //
            // Display the data that SSI is transferring.
            //
            UARTprintf("'%c' ", pui32DataTx[ui32Index]);
    
            //
            // Send the data using the "blocking" put function.  This function
            // will wait until there is room in the send FIFO before returning.
            // This allows you to assure that all the data you send makes it into
            // the send FIFO.
            //
            SSIDataPut(SSI0_BASE, pui32DataTx[ui32Index]);
        }

    前8位数据左移16位然后和后16位相或不就可以了么。虽然SSIConfigSetExpClk()能发送的数据帧长度范围为4~16,但是

    SSIDataPut的参数是u32的。你可以可以单独8位8位的发,一起组合为一个u32的数据需要你测试下,没看数据手册,不知道SSIConfigSetExpClk()能发送的数据帧长度范围为4~16是否就是SSI的FIFO的长度呢?如果是的话,那就不能组合了。
  • 1.用FIFO,每一级的FIFO发完后会拉高片选吗(SYNC)?
    DAC8534手册上要求24bit移位结束之前是不能拉高SYNC的。否则之前的移位数据无效。
    你这种每次8位,然后FIFO的方式能用吗?

    2.第二个问题,如果片选SYNC由普通IO口来模拟,且同时使能FIFO,这样可以吗?软件在什么时候拉高或拉低,怎么知道24bit啥时移位完成?