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.

programming I2C on dm6446 wih CCS



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;

 

--------------------------------------------------------------------

  • Hi Eric,

    I have attached a small i2c Linux program (less than a page) that demonstrates how to toggle LEDs using our Linux drivers.  You may need to edit makefile to point to correct the paths for your build environment.  I hope this helps.

     

    led.zip
  •  

    Thanks, but  I am umfamiliar Linux driver, is the file need below list   in "driver\ i2c\" of PSP   that attached file?

    i2c-dev.c,  i2c-core.c, i2c-davinci.c,and i2c-davinci.c  file.

    I program I2C following I2C datasheet , I don't known why the BB ( Bus busy) bit's stae  change to  high immediiately  after enable the I2C controller?

     

  • yes, you are looking at the correct Linux source code for the driver; however, I would not recommend trying to port it over to CCS, it will probrably not work as it has Linux OS dependacies. 

    Our software offering for DM6446 relies heavily on Linux OS; additionally, there are third parties that will support other OSes (WinCE, Integrity, QNX...) for a fee.  This part is quite complex, and managing the ARM hardware normally requires a higher level OS; at least I am not aware of many customers using ARM intrisic instructions to write their applications.  This is the reason we provide Linux and teamed up with other third parties on additional software offerings.

  • Thanks,

    I think I2C module maybe not working , beasuse there is some configuration not correct to set. So,I want to know   what is must to turn on before  using that module. I refer document of spreu14b P.93 . Is taht mean I must to turn on clock and power before using the module? But I don't know how to turn on clock of the module. I guess turn on clock of module when I turn on PSC.

    If I want to check statu of that module, Is that I need to look MDSTAT18(Module staus of I2C) register of PSC? I check the module state status filed (bit 5~0 ) of I2C of PSC that the value is 0h(SwRstDisable state), I try to programming MDCTL18(module control register of I2C) seeting next state as 3h(enable state), but it is not working on MDSTAT18 that value is not change(SwRstDisable state).

  • I have  the same question .Have you  solve it  ?

     

  • Because peripherals share pins with GPIO, you must power on the module and setting PINMUX1 reg before you o program I2C module. You could refer  P.74 on "tms320dm6446.pdf"(TMS320DM6446 Digital Media System-on-Chip (Rev. F)), there is some informantion about PINMUX1.

  • Thank you very  much !!

    I  have  solved  it .

    very  happy!

  • thank you !

    1.           How to  power  on  I2C module ? 

                   P.72 on "tms320dm6446  ARM  subsystem .pdf"(Rev. B)) says I2C module is alwayson.

     

    2.          I configure  Module Control  18 Register (I2C)  (MDCTL18,address= 0X01c41a48)   ,   the value is 3h.  

                 Have  I t urn on  I2C module's clock ??