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...