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.

Changing the Sampling Rate of ADS8328 on Pulse Oximeter Front End Board C5515EVM

Other Parts Discussed in Thread: ADS8328

Hi everyone,

I am an absolute beginner with the TI DSP programming and the CCS. I would really appreciate if someone can help me a bit. I have the Pulse Oximeter Front End Board along with C5515 EVM. I know the sampling rate of ADS8328 is set at 500 samples per second. I am looking at the code in CCS but I cannot understand where and how the rate is being set. I want to do some experiments with the board (to get a better understanding of it) starting with changing the sampling rate. I tried looking at the online resources and some other pages but did not get much help.

Could anyone please help me? I want to know how to set the sampling rate of ADS8328 on the Pulse Oximeter Front End Board connected to the C5515EVM. I am using CCSv4.

Thanks a lot for your time and help.

Regards.

  • Hi,

    Moving back to C5000 device forum to address your request.

    Thanks & regards,

    Sivaraj K

  • Hello,

    do you have the source code example yet? If yes, maybe you could attach here, so I can take a look into it.

    Regards,

    V

  • Hi,

    This is the code snippet which came with the Pulse Oximeter Front End Board. I know they are using 500 Hz as the sampling rate but I cannot see where is it defined.

    SpO2_Status SpO2_ADS8328_INIT()
    {
    PSP_Result Status = 0;

    // Uint16 cmdVal[4] = {0,0,0,0}; /* Variable to store the cmd value*/
    Uint16 *SPIBuf = 0; /* SPI Tx or Rx Buffer*/
    Uint16 SPICount = 1; /* SPIBuff count*/
    Uint16 SPICmdBuf[4] = {0xE6FF,0xC000,0x0FFF,0xD000} ; /* Buff to store the cmd*/
    Uint16 SPICmdCount = 0; /* CmdBuff count*/
    Uint16 SPIReadOrWrite = SPI_WRITE; /* Variable to store the current operation of SPI*/
    Uint16 SPIBufRece[3] = {0,0,0};
    // Uint16 ADS8328RegVal[1] = {0xE6FF}; /* Value to be sent to Configuration register*/
    // Uint16 RegisterData = 0;


    /* Give CFR Read command*/

    SPICount = 0;
    SPICmdCount = 1;

    SPIBuf = 0;

    // SPICmdBuf = 0x0C;//(CMD_READ_CONFIG_REG);
    SPIReadOrWrite = SPI_READ;


    SPI_READ_WRITE_N_BYTES(SPIBufRece,SPICount,SPICmdBuf,SPICmdCount,SPIReadOrWrite);

    /* CFR Data Read */


    SPIBufRece[0] = *((ioport volatile unsigned*)0x3009); //SPIDATA1 reg


    SPI_READ_WRITE_N_BYTES((Uint16*)&SPIBuf,SPICount,&SPICmdBuf[1],SPICmdCount,SPIReadOrWrite);

    /* CFR Data Read */


    // SPIBufRece[0] = *((ioport volatile unsigned*)0x3009); //SPIDATA1 reg

    // SPIBufRece[0]=0;
    // SPIBufRece[1] = 0;

    // RegisterData = (*SPIBuf) >> 4;

    return Status;
    }

    Any help would be highly appreciated.

    Thanks.

  • The SPI Clock is configured through the SPICDR Register on address 0x3000h

    In my opinion, we can figure out the sampling rate through this SPI clock rate.

    But on the data that you copied above, I did not see the set of this Register.

    Could you read through (or may be copy here again) the initialization of the CPU, possibly it is configured there.

    Regards,

    V

  • Hi Vava,

    Thanks for your reply. I did not find SPICDR in the code but I am pasting the SPI initialization here:

    SpO2_Status SpO2_SPI_INIT()
    {
    SpO2_Status Status;
    DDA_spiConfig spiConfig;
    // Uint16 spiClkRate = 7000000; /* 7MHz Max possible for SPI, but not used- hardcoded */
    /* the SPI_PRESCALE to 13 so as to achieve 7MHz */
    Uint16 spiClkRate = 53184; /* 53.184 KHz Max possible for SPI, but not used- hardcoded */
    /* the SPI_PRESCALE to 13 so as to achieve 7MHz */
    Uint16 frameLen = 0; /* Frame Len 0 for 1 word */
    Uint16 wordLen = 16; /* Word length 16 */
    Uint16 slaveNo = 0; /* SlaveNo 0 */
    Uint16 dataDly = 0; /* delay 0 */
    Uint16 csPol = 0; /* cspol 0 */
    Uint16 clkPh = 0; /* clkphase 0 */
    Uint16 clkPol = 1; /* clkpol 1 */

    Status = SPI_FAILURE;

    /* Driver configuration initialization */

    spiConfig.spiCtrlMode = SPI_MODE; /* SPI Mode */
    spiConfig.spiMaster = SPI_MASTER; /* SPI Master */
    spiConfig.opMode = SPI_POLLED; /* SPI polling mode */
    spiConfig.instances = SPI_SINGLE_INST; /* Single instance */
    spiConfig.syncMode = SPI_SYNC; /* Sync Mode */

    /* Initialize the SPI with */
    Status = SPI_INIT(spiConfig,spiClkRate,frameLen,wordLen,slaveNo,dataDly,csPol,clkPh,clkPol);

    *((ioport volatile unsigned*)0x3002) = 0x01; // clkpol =1,

    return Status;
    }

    Should I also copy the cpu_clock_init()?

    Thanks again!

  • Hi,

      Can you look at  "llc_spi.c" file, the definition of the SPI clock rate/other functions resides in this file.

      Below is code snippet for your reference. 

    /***********************************************************************

    PSP_Result LLC_spiInit(
                     Uint16 spiClkRate,
                     Uint16 frameLen,
                     Uint16 wordLen)
    {
        PSP_Result result = PSP_SOK;

    //    spiReg = (CSL_SpiRegs *)(CSL_SPI_REGS);

        LLC_SPI_Disable();

        LLC_SPI_ClockSet(spiClkRate);

        result = LLC_SPI_WLenSet(wordLen);
        if (result != PSP_SOK)
            return (result);

        result = LLC_SPI_FLenSet(frameLen);
        if (result != PSP_SOK)
            return (result);

        LLC_SPI_WordInterruptEnable();

        LLC_SPI_Enable();

        return (result);
    }

    void LLC_SPI_ClockSet(Uint16 spiClkRate)
    {
     Uint16 sysClkDiv;
     extern Uint32 sysClk;
    // Uint32 sysClk = 100000;

        if(sysClk <= 10000)
     {
            sysClkDiv = SPI_PRESCALE; //99
     }
     else
     {
      sysClkDiv = spiDivFun(sysClk, spiClkRate);
      /* clock diviser increased by 2 as sysClk is not taking same value as
       system clock speed */
         sysClkDiv = sysClkDiv + 2 ;
     }
        CSL_SPI_REGS->SPICC1 = sysClkDiv;
    }

    Void LLC_SPI_ClockSet(Uint16 spiClkRate)
    {
     Uint16 sysClkDiv;
     extern Uint32 sysClk;
    // Uint32 sysClk = 100000;

        if(sysClk <= 10000)
     {
            sysClkDiv = SPI_PRESCALE; //99
     }
     else
     {
      sysClkDiv = spiDivFun(sysClk, spiClkRate);
      /* clock diviser increased by 2 as sysClk is not taking same value as
       system clock speed */
         sysClkDiv = sysClkDiv + 2 ;
     }
        CSL_SPI_REGS->SPICC1 = sysClkDiv;
    }

    ************************************************************************************************/

    Hope the above information helps.

    Also, This application may no longer supported by TI, so you may get very limited help on this.

    Regards

     Vasanth

  • Hi Vasanth,

    Thank you so much for taking the time to help me. I found that the SPI clock rate is:

    Uint16 spiClkRate = 53184;

    Could you please tell me the relation between the SPI clock rate and the sampling rate?

    Thanks again!

  • I am also pasting the code snippet talking about spiclkrate (from ll_spi.c):

    void LLC_SPI_ClockSet(Uint16 spiClkRate)
    {
    Uint16 sysClkDiv;
    extern Uint32 sysClk;
    // Uint32 sysClk = 100000;

    if(sysClk <= 10000)
    {
    sysClkDiv = SPI_PRESCALE; //99
    }
    else
    {
    sysClkDiv = spiDivFun(sysClk, spiClkRate);
    /* clock diviser increased by 2 as sysClk is not taking same value as
    system clock speed */
    sysClkDiv = sysClkDiv + 2 ;
    }
    CSL_SPI_REGS->SPICC1 = sysClkDiv;
    }