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.

DAC60508: No output. Problem to write to register with SPI ? (spidev, python)

Part Number: DAC60508

Hello,

I'm a beginner with SPI protocol and I want to control the DAC60508.

I wrote the python script with "spidev" library and the DAC is connected with a raspberry PI in a default pins for SPI. (The SPI protocol is correctly activated in a rasberry OS)

import spidev
import time

spi = spidev.SpiDev()

cs_port = 0
spi.open(0, cs_port)

spi_max_speed_hz = 100000
spi.mode = 0


# This function because the MSB is right aligned
def ReverseBits(byte):
    byte = ((byte & 0xF0) >> 4) | ((byte & 0x0F) << 4)
    byte = ((byte & 0xCC) >> 2) | ((byte & 0x33) << 2)
    byte = ((byte & 0xAA) >> 1) | ((byte & 0x55) << 1)
    return byte
    
def write_data(addr, data1, data2):
    spi.writebytes([addr, ReverseBits(data1), ReverseBits(data2)])


def change_cs():
    spi.cshigh = not spi.cshigh
    
    
if __name__ == '__main__':
    # The main script
    
    spi.cshigh = True
    
    time.sleep(1)

    write_data(0x2,  0, 0) # Write in SYNC
    change_cs()
    
    time.sleep(1)
    
    change_cs()
    write_data(0x3, 0, 0) # Write in config
    change_cs()
    
    
    time.sleep(1)
    
    change_cs()
    write_data(0x4, 1, 0) # Write in GAin (1 everywhere)
    change_cs()
    
    
    time.sleep(1)
    
    change_cs()
    write_data(0x5, 0, 0) # Write in Trigger
    change_cs()
    
    
    time.sleep(1)
    
    
    change_cs()
    write_data(0x6, 0, 0) # Write in Broadcast 
    change_cs()
    
    
    time.sleep(1)
    
    change_cs()
    write_data(0x7, 0, 0) # Write in Status
    change_cs()
    
    
    time.sleep(1)
    
    change_cs()
    write_data(0x8, 184, 11) # Write 3000 in dac0
    
    
    time.sleep(1)

With this code, nothing is happening. I think I read the doc point by point though...

  • Hi , Thanks for reaching E2e.

    1. Please share your hardware schematic / test setup. , voltage rail for each power rails ?

    2. Are you able to get SPI waveforms based on you code ? share scope snaps

    3. We can't support python review of script but we can review your schematic and review you pseudo code.