This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

DAC 7562 With NRF51822

Hi, Basically, I have a DAC 7562 chip with inputs connected to pin 0.17(SYNC pin), 0.18(SCLK pin), 0.19(TX/Din pin), 0.13(CLR pin), 0.14(LDAC pin) with outputs connected to an op-amp connected to P0.01. Please can anyone show me some example code of how I can configure my DAC chip to supply voltage to the output pin within the range of 0.9v to 1.8v? I am programming with keil. Thank you.

  • If you look at the timing diagram on page 7 of the DAC7562 datasheet, in order to make it work you would need a clock signal to shift data in to the input register on the DAC (SCLK pin), a signal to enable the input shift register (SYNC pin) and the serial data itself (DIN pin).

    To me this looks very similar to the SPI protocol. SPI has a clock (SCK), a slave select (SS) and a data wire from master to slave (MOSI).

    You can start by looking at the spi_master example in the SDK (v7.2.0).

    In the DAC7562 datasheet it is specified on page 6 that the DIN register takes 24 bits. This corresponds to 3 bytes over the SPI bus.

    If you start with the spi_master example code, you could achieve this by simply replacing the main() function with this code:

    int main(void){
        bsp_configuration();
    	uint8_t tx_data[3] = {0xAA, 0xAB, 0xAC}; // Fill in the 24 bits you want to write here.
    	uint8_t rx_data[3];
        spi_master_init(SPI_MASTER_0, spi_master_0_event_handler, true);
        spi_master_send_recv(SPI_MASTER_0, tx_data, 3, rx_data, 3);
        for (;; ){}
    }
    

    Of course you need to change the pin configuration of the SPI interface. In the spi_master_init() function in main.c the SCK, SS and MOSI pins are defined. You can simply change this to the pins you prefer. For example:

    spi_config.SPI_Pin_SCK  = 18;
    

    Hope this will get you started.

    EDIT 04.03.15:

    To answer the questions in your comment:

    The CLR and LDAC operation is specified in table 2 in the datasheet. CLR pin is driven low to clear the output. If you do not want to clear the output you must set this pin high. LDAC is used when the DAC is operating in asynchronous mode (which is also described in the same table), if you are fine with synchronous mode you can connect this to GND.

    If you want to connect all the pins to the nRF51 you can control the output voltages of the different pins with:

    #include "nrf_gpio.h"
    nrf_gpio_cfg_output(PIN_NUMBER) //Set as output
    nrf_gpio_pin_set(PIN_NUMBER) //Set high
    nrf_gpio_pin_clear(PIN_NUMBER) //Set low (GND)
    

    The bits to write on the DIN pin i don't know, but I'm pretty sure that is specified in the datasheet of the DAC.

    You have to declare the MISO pin. Just assign it to an unused pin if you are not going to use it.

  • thanks I will look into this and give feedback...but what about the CLR pin and the LDAC pin? Also, seeing as its a DAC and not a proper communication channel, how do I know the bits to write for the Din pin?? Also, do I just ignore the MISO pin declaration?? Sorry i'm really new to all this

Related