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.

eZDSP, migration from BSL to CSL

I've just finished some software for ezdsp stick using BSL. I would rather use CSL, so I've written substitutes for BSL functions, such as AIC3204_rset( Uint16 regnum, Uint16 regval ) and so on. However, I am not sure what to do with things like: SYS_EXBUSSEL |= 0x0020; USBSTK5505_I2C_init( ); etc. My initializing code is based on examples and CSL reference but it doesn't work. I2C_write always returns 0x0001 which is not even proper value of SCL_Status. Maybe someone would tell me, how I2C shold be configured? Here is my code:

 

CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP0MODE, MODE2);

hGPIO = GPIO_open(&GpioObj,&status);
config.pinNum = CSL_GPIO_PIN26;
config.direction = CSL_GPIO_DIR_OUTPUT;
config.trigger = CSL_GPIO_TRIG_FALLING_EDGE;
GPIO_configBit (hGPIO, &config);

status = GPIO_write(hGPIO,CSL_GPIO_PIN26,1); 

i2cSetup.addrMode = CSL_I2C_ADDR_7BIT;
i2cSetup.bitCount = CSL_I2C_BC_8BITS;
i2cSetup.loopBack = CSL_I2C_LOOPBACK_DISABLE;
i2cSetup.freeMode = CSL_I2C_FREEMODE_DISABLE;
i2cSetup.repeatMode = CSL_I2C_REPEATMODE_DISABLE;
i2cSetup.ownAddr = CSL_I2C_OWN_ADDR;
i2cSetup.sysInputClk = CSL_I2C_SYS_CLK;
i2cSetup.i2cBusFreq = CSL_I2C_BUS_FREQ;

status = I2C_init(CSL_I2C0);
status = I2C_setup(&i2cSetup);

void AIC3204_rset( Uint16 regnum, Uint16 regval )
{
 Uint16 startStop = ((CSL_I2C_START) | (CSL_I2C_STOP));
 CSL_Status  stat;
 Uint16 cmd[2];
 cmd[0] = regnum & 0x007F; // 7-bit Device Address
 cmd[1] = regval; // 8-bit Register Data

 stat=I2C_write(cmd, 2 ,0x0018, TRUE, startStop, CSL_I2C_MAX_TIMEOUT);
 
}

 

 

 

  • Hi,

     

    This is a good question. Since Spectrum digital has not used CSL when they made example codes. Instead they used BSL.

    TI want to use more CSL than BSL so I'll take a close look this case.

    Regards.

    Hyun

  • Hello, Hyun Kim.

     I have to say, that I've been little too less observant. When I wrote previous message, I did not realize there are both - .h and .c source files delivered with bsl library. Thanks too that, it's possible to figure out peripherals configurations and adapt them to CSL. I've already written correct gpio configuration code,so just have to find out what is wrong with I2C. I will provide here solution, when I will have one.

     

    edit:

     Problem is solved. Here is  my working source code:

    GPIO

    CSL_FINST(CSL_SYSCTRL_REGS->EBSR, SYS_EBSR_SP0MODE, MODE2);
    hGPIO = GPIO_open(&GpioObj,&status);
    config.pinNum = CSL_GPIO_PIN26;
    config.direction = CSL_GPIO_DIR_OUTPUT;
    GPIO_configBit (hGPIO, &config);
     status = GPIO_write(hGPIO,CSL_GPIO_PIN26,1);

    I2C

    i2cSetup.addrMode = CSL_I2C_ADDR_7BIT;
    i2cSetup.bitCount = CSL_I2C_BC_8BITS;
    i2cSetup.loopBack = CSL_I2C_LOOPBACK_DISABLE;
    i2cSetup.freeMode = CSL_I2C_FREEMODE_DISABLE;
    i2cSetup.repeatMode = CSL_I2C_REPEATMODE_DISABLE;
    i2cSetup.ownAddr = CSL_I2C_OWN_ADDR;
    i2cSetup.sysInputClk = CSL_I2C_SYS_CLK;
    i2cSetup.i2cBusFreq = CSL_I2C_BUS_FREQ;
    I2C_init(CSL_I2C0);
    I2C_setup(&i2cSetup);

     Writing to Codec

    Int16 AIC3204_rset( Uint16 regnum, Uint16 regval )
    {
      int dummy=10000;
       Uint16 cmd[2];
       cmd[0] = regnum & 0x007F; // 7-bit Device Address
       cmd[1] = regval; // 8-bit Register Data

      while(dummy) dummy--; 

    return I2C_write(cmd,2,AIC_ADDR, TRUE, (CSL_I2C_START)|(CSL_I2C_STOP), 0x7fff);
    }

     

    It's very important to wait until I2C is ready to transmit new byte.Unfortunately, CSLfor VC5505 doesn't provide I2C_xrdy function. Thats why I use dummy loop. CSL_i2C_BUS_FREQ can be any value (in kHz) from range defined in aic3204 datasheet.

     Regards    

  • Thanks for your try.

    I hope that you find the way.

    Regards,

    Hyun

  • EDIT:

    Here is another part of code - I2S config structure. This one and few posted above, are all what is needed to recode examples in CSL instead BSL.

    I2S:

    I2ShwConfig.dataFormat = I2S_DATAFORMAT_LJUST;
    I2ShwConfig.i2sMode = I2S_SLAVE;
    I2ShwConfig.wordLen = I2S_WORDLEN_16;
    I2ShwConfig.signext = I2S_SIGNEXT_DISABLE;
    I2ShwConfig.datapack = I2S_DATAPACK_DISABLE;
    I2ShwConfig.datadelay = I2S_DATADELAY_ONEBIT;
    I2ShwConfig.clkPol = I2S_RISING_EDGE;
    I2ShwConfig.fsPol = I2S_FSPOL_LOW;
    I2ShwConfig.loopBackMode = I2S_LOOPBACK_DISABLE;
    I2ShwConfig.dataType = I2S_STEREO_ENABLE;
    I2ShwConfig.clkDiv = I2S_CLKDIV2;
    I2ShwConfig.fsDiv = I2S_FSDIV8;
    I2ShwConfig.FError = I2S_FSERROR_ENABLE;
    I2ShwConfig.OuError = I2S_OUERROR_ENABLE;

     Have fun!