Tool/software:
Hello,
Here is my script I used to program PCM9211 over I2C interface. As I2C master I use Digital Discovery device:
from ctypes import * from dwfconstants import * import time I2C_freq = 100e3 SCL_PIN = 24 # Change if needed SDA_PIN = 25 # Change if needed I2C_ADDR_MAX98089 = 0x10 I2C_ADDR_PCM9211 = 0x40 I2C_ADDR = I2C_ADDR_PCM9211 dwf = cdll.dwf hdwf = c_int() iNak = c_int() dwf.FDwfDeviceOpen(c_int(-1), byref(hdwf)) if hdwf.value == hdwfNone.value: print("failed to open device") quit() dwf.FDwfAnalogIOChannelNodeSet(hdwf, c_int(1), c_int(0), c_double(3.3)) dwf.FDwfAnalogIOEnableSet(hdwf, c_int(True)) print("Configuring I2C...") iNak = c_int() dwf.FDwfDigitalI2cRateSet(hdwf, c_double(I2C_freq)) dwf.FDwfDigitalI2cSclSet(hdwf, c_int(SCL_PIN)) dwf.FDwfDigitalI2cSdaSet(hdwf, c_int(SDA_PIN)) dwf.FDwfDigitalI2cClear(hdwf, byref(iNak)) if iNak.value == 0: print("I2C bus error. Check the pull-ups.") quit() time.sleep(1) #Configure PCM9211 # 1. To enable DIT Standalone Mode, set Register 0x6F = 0x05 DIT_Standalone_Mode_En = (0x6F, 0x05, "Enable DIT Standalone Mode, MPIO_C3 = TXDIN, MPIO_C1 = TXBCK, MPIO_C2 = TXLRCK") # 2. Set master clock XMCKO as XTI/2, i.e. 12.288 MHz Master_CLK_Freq = (0x24, 1<<2, "Set master clock to 12.288MHz") # 3. Enable S/PDIF on MPO0 and XMCKO on MPO1 (p. 111) MPO0_DITOUT = (0x78, 0x0D | 0x0C << 4, "Route DIT Output (TXOUT) to MPO0 and XMCKO to MPO1") # 4. Select RXIN0 as the S/PDIF Input (DIR) DIR_RXIN0 = (0x34, 0x00, "Select RXIN0 as input for DIR") # 5. Route DIR Output to Main Output Port (MOP) MOP_DIR = (0x6B, 0x01, "Route DIR Output to Main Output Port (MOP)") Config_PCM9211 = (DIT_Standalone_Mode_En, Master_CLK_Freq, MPO0_DITOUT, DIR_RXIN0, MOP_DIR) for reg_addr, reg_value, comment in Config_PCM9211: data = (c_ubyte*2)(reg_addr, reg_value) dwf.FDwfDigitalI2cWrite(hdwf, c_int(I2C_ADDR<<1), data, c_int(2), byref(iNak)) if iNak.value != 0: print("Device power NAK "+str(iNak.value)) quit() else: print(comment) dwf.FDwfDeviceCloseAll()
Here is output:
================= RESTART: C:\Users\pyoha\Documents\WORK\Python_scripts\programming_motherboard_over_i2c.py =================
Configuring I2C...
Enable DIT Standalone Mode, MPIO_C3 = TXDIN, MPIO_C1 = TXBCK, MPIO_C2 = TXLRCK
Set master clock to 12.288MHz
Route DIT Output (TXOUT) to MPO0 and XMCKO to MPO1
Select RXIN0 as input for DIR
Route DIR Output to Main Output Port (MOP)
But when I try to measure signal at MPO1 pin of PCM9211 (using "Logic" interface of Digilent's WaveForms software), I don't see any signal ... but expect to see 12.888MHz.