I am trying to program I2C with I/O expander LEDs on dm6446 on CCS. I know there has driver of I2C for dm6446 on PSP, but the driver is too complex to use for me. I just want to take easy test (read & write) between 8-LEDs and ARM by I2C. I refer the document of sprue27c page.20 (dm644x I2C peripheral manual) to setting I2C. I set I2C in master and receiver operation mode to receive from 8-Leds(I2C address :0x38). My application code stall on check BB(bus busy)=0 in ICSTR, it is keep high of BB bit.I have no ideal about how to debug the problem.
My application code is based on the following link(ARM-side). I had check the PSC(Power and sleep controller) status of I2C module of MDSTANT18 register(0x01c41848), the register change value from 0x00F02 to 0x01F03 after PSCModuleON execute, so I am sure the I2C module could work. I try to measure the signal of I2C_CLK(pin18) and I2C_data(pin20) from DC3 connector on DM6446 evaluation module by oscilloscope, the two signals approach 2 voltage with no change, even I had configure I2C clock frequency to operate 100khz(standard mode).
http://tiexpressdsp.com/index.php?title=HOWTO_Turn_off_DSP_clock_and_Power
There is my programming I2C code below. Is there have any problem on code?
---------------------------------------------------------------
//disable I2C
I2C->ICMDR &= (~I2C_ICMDR_IRS);
//configure ICMDR
I2C->ICMDR = (1<<10) //set I2C master
|(0<<9) //Receiver mode
|(0<<8) // 7-bit address mode
|(0<<7) //disable repeat mode
|(0<<6) //disable loop back mode
|(0<<4) //disable start byte mode
|(0<<3) //free data mode
|(0<<0); //8-bits per data word
I2C->ICSAR =0x38; //slave address
I2C->ICPSC =2; //9MHz
I2C->ICCLKH = 40;
I2C->ICCLKL = 40; //9M/(45+45)=100khz
I2C->ICSTR=I2C->ICSTR;
while(I2C->ICIVR!=0); //wait ICIVR is zero
I2C->ICIMR |=(1<<3); //enable ICRRDY interrupt
I2C->ICMDR |= I2C_ICMDR_IRS; //enable I2C
while(I2C->ICSTR &(1<<12)); //wait until BB bit cleared <<----------- stall here
I2C->ICMDR|=(1<<13); //gererate start event
while(I2C->ICSTR & (1<<4));
temp=I2C->ICDRR;