DAC60508: DAC60508ZCRTER with AM6442 Linux

Part Number: DAC60508
Other Parts Discussed in Thread: AM6442,

Tool/software:

Hi Team,

We are using DAC60508ZCRTER chip in one of our projects and it's connected to AM6442 processor. Below is the dts setting for SPI

&main_spi1 {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&main_spi1_pins_default>;
cs-gpios = <&main_gpio1 47 GPIO_ACTIVE_LOW>;
ti,pindir-d0-out-d1-in;

spidev0: spidev@0 {
compatible = "lwn,bk4";
reg = <0>; /* Chip select 0 */
spi-max-frequency = <1000000>; /* Adjust as per your device */
#address-cells = <1>;
#size-cells = <0>;
};

};

main_spi1_pins_default: main-spi1-default-pins {
pinctrl-single,pins = <
AM64X_IOPAD(0x0224, PIN_INPUT, 0) /* (C14) SPI1_CLK */
/*AM64X_IOPAD(0x021c, PIN_OUTPUT_PULLDOWN, 0) /* (B14) SPI1_CS0 */
AM64X_IOPAD(0x021c, PIN_OUTPUT_PULLDOWN, 7) /* (B14) SPI1_CS0: GPIO1_47 */
AM64X_IOPAD(0x0228, PIN_OUTPUT, 0) /* (B15) SPI1_D0 */
AM64X_IOPAD(0x022c, PIN_INPUT, 0) /* (A15) SPI1_D1 */
>;
};

with this I am using C application to communicate with the DAC device which i will attach here

#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/spi/spidev.h>
#include <string.h>
#include <errno.h>

#define DEVICE "/dev/spidev2.0" // Adjust for your system
static int spi_fd;

// ---------------- SPI Init ----------------
int spi_init(const char *device) {
int mode = SPI_MODE_0; // DAC60508 uses SPI Mode 0
int bits = 8;
int speed = 1000000; // 1 MHz safe start

spi_fd = open(device, O_RDWR);
if (spi_fd < 0) {
perror("open");
return -1;
}
if (ioctl(spi_fd, SPI_IOC_WR_MODE, &mode) < 0) {
perror("SPI mode");
return -1;
}
if (ioctl(spi_fd, SPI_IOC_WR_BITS_PER_WORD, &bits) < 0) {
perror("SPI bits");
return -1;
}
if (ioctl(spi_fd, SPI_IOC_WR_MAX_SPEED_HZ, &speed) < 0) {
perror("SPI speed");
return -1;
}

return 0;
}

// ---------------- DAC Read ----------------
int dac60508_read(uint16_t reg, uint16_t *value) {
uint8_t tx[4], rx[4] = {0};

tx[0] = 0x20 | ((reg >> 8) & 0x0F); // CMD=2 (READ)
tx[1] = reg & 0xFF; // Register address
tx[2] = 0x00; // dummy
tx[3] = 0x00; // dummy

struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)tx,
.rx_buf = (unsigned long)rx,
.len = 4,
.speed_hz = 1000000,
.bits_per_word = 8,
};

if (ioctl(spi_fd, SPI_IOC_MESSAGE(1), &tr) < 0) {
perror("SPI read");
return -1;
}

*value = ((uint16_t)rx[2] << 8) | rx[3];
return 0;
}

// ---------------- DAC Write ----------------
int dac60508_write(uint16_t reg, uint16_t value) {
uint8_t tx[4];

tx[0] = 0x10 | ((reg >> 8) & 0x0F); // CMD=1 (WRITE)
tx[1] = reg & 0xFF;
tx[2] = (value >> 8) & 0xFF;
tx[3] = value & 0xFF;

struct spi_ioc_transfer tr = {
.tx_buf = (unsigned long)tx,
.rx_buf = 0,
.len = 4,
.speed_hz = 1000000,
.bits_per_word = 8,
};

if (ioctl(spi_fd, SPI_IOC_MESSAGE(1), &tr) < 0) {
perror("SPI write");
return -1;
}
return 0;
}

// ---------------- Main ----------------
int main(int argc, char *argv[]) {
uint16_t status = 0;

if (spi_init(DEVICE) < 0)
return 1;

// Step 1: Read STATUS register (0x05)
if (dac60508_read(0x05, &status) == 0) {
printf("DAC60508 STATUS = 0x%04X\n", status);
} else {
printf("Failed to read STATUS!\n");
}

// Step 2: Optionally write a DAC channel
if (argc == 3) {
int channel = atoi(argv[1]); // 0–7
int value = atoi(argv[2]); // 0–65535 (16-bit full scale)

if (channel < 0 || channel > 7) {
printf("Invalid channel: %d (must be 0–7)\n", channel);
close(spi_fd);
return 1;
}

uint16_t reg = 0x08 + channel; // DACx_DATA registers start at 0x08

if (dac60508_write(reg, (uint16_t)value) == 0) {
printf("Wrote DAC%d = %d (0x%04X)\n", channel, value, value);
} else {
printf("Failed to write DAC%d\n", channel);
}
} else {
printf("Usage: %s <channel 0-7> <value 0-65535>\n", argv[0]);
}

close(spi_fd);
return 0;
}

Device is running on Linux OS and when device boots I can see /dev/spidev2.0 getting list. Problem is that when the communication starts i cannot see SPI_CS going LOW it stays HIGH always

Could you please tell me what is been missed. Below is the schematic snapshot

Please help us here

Regards,

Shwetha Nayak

  • Shwetha,

    For the time being, I'm going to move this post to the processors forum. In the data converters group, we don't have a lot of experience with these processors, and if  you're having problems getting the /CS line to change, then I think they'll be able to help you. 

    If you're able to get the SPI working (with the /CS, DIN, and SCLK lines) then we'll be able to help with the DAC60508 communication.

    Joseph Wu