I'm trying to interface my ADSP-21488 with a DAC chip via the Two-Wire Interface (I2C). I wanted to start easy and use the master mode transmit for writing certain registers in the DAC, which means addressing the chip correctly (with TWIMADDR) and writing two consecutive bytes (register address + data via TXTWI8).
But I can't even get that to work. I am monitoring things by stepping thru with a HPUSB-ICE. Everything goes smoothly and makes sense up to the point were I set TWIMEN in the TWIMCTL, then TWIRERR is immediately set in TWIMSTAT, although I have written the two bytes into TXTWI8.
Do I have to consider another PRESCALE when I am running with HPUSB-ICE, perhaps because PCLK is behaving differently?
Anybody have an idea what I might be doing wrong?
A little help would be greatly appreciated.
Excerpts from my asm-code:
* Init ES9018K2M DAC chip
/* SRU route */
SRU2(LOW,DPI_PB06_I); // DPI Pin Buffer 6 as open drain (I2C_CLK)
SRU2(TWI_CLK_PBEN_O, DPI_PBEN06_I); // TWI clock output -> DP6 PBEN (I2C_CLK)
SRU2(DPI_PB06_O, TWI_CLK_I); // DP6 -> TWI clock input (I2C_CLK)
SRU2(LOW,DPI_PB08_I); // DPI Pin Buffer 8 as open drain (I2C_DATA)
SRU2(TWI_DATA_PBEN_O, DPI_PBEN08_I); // TWI data output -> DP8 PBEN (I2C_DATA)
SRU2(DPI_PB08_O, TWI_DATA_I); // DP8 -> TWI data input (I2C_DATA)
* Enable TWI module, set PRESCALE
* CCLK = ClkCrystal (CLKIN) * ClkRatio (CLK_CFG) = 25MHz * 8:1 = 200MHz
* PCLK = CCLK/2 = 100MHz
* PRESCALE = PCLK/10MHz = 10
ustat1 = TWIEN|0xA;
dm(TWIMITR) = ustat1;
* CLKDIV = TWI_CLOCK period ÷ 10 MHz time reference.
* CLKLOW and CLKHI add up to CLKDIV.
* (1/50kHz)/(1/10MHz) = 200 = 100+100 = 0x64+0x64
ustat1 = 0xc8c8;
dm(TWIDIV) = ustat1;
* ESS I2C chip address
ustat1 = ESS_DEVICE_ID;
dm(TWIMADDR) = ustat1;
* Write register
* r0: (register address)
* r1: (write data)
ustat1 = TWITXFLUSH|TWIRXFLUSH|TWIBHD;
dm(TWIFIFOCTL) = ustat1;
ustat1 = dm(TWIMSTAT);
dm(TWIMSTAT) = ustat1; // clear status bits
ustat1 = TWIMCOM|TWIMERR;
dm(TWIIRPTL) = ustat1; //clears the complete/error interrupt
dm(TXTWI8) = r0;
dm(TXTWI8) = r1;
ustat1 = (TWIDCNT&(2<<6));
dm(TWIMCTL) = ustat1;
ustat1 = dm(TWIMCTL);
bit set ustat1 TWIMEN;
dm(TWIMCTL) = ustat1;