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.

C5515 SAR Channel 2 problem

I am attemting to measure voltage of the battery with channel 2. (The GND_ON bit is set to zero).

The problem is I always read zeros.

All other channels (including channel 1, when GND_ON is set to 1)  work perfectly. So I guess my configuration and usage of the register is ok.

The voltage is much less than VDD_ANA.

Any ideas ?

Thanks.

 

My code is :

 // Set SAR clock dividor. Clock must be maximum 2 Mhz 
     CSL_SAR_REGS->SARCLKCTRL = (DSP_SYSTEM_CLOCK_MHZ / 2) + 20;
    
    // Set GPAIN 2 and 3 to GP output
    CSL_SAR_REGS->SARGPOCTRL = 0xC0;
if (chanNo == 1)

    {
        CSL_SAR_REGS->SARPINCTRL = /*0x3600;*/0x3602;
    }
    else if (chanNo == 2)
    {
        CSL_SAR_REGS->SARPINCTRL = 0x3600;
    }
    else
    {
        CSL_SAR_REGS->SARPINCTRL = 0x3600;
    }

    for(i=0;i<100;i++);
    
    Uint16 x = 30;
    
    while (x > 0)
    {

        // Start Single Conversion
        CSL_SAR_REGS->SARCTRL = 0x8000 | (chanNo << 12) | 0x400 ;//| 0x800;
        
        for(i=0;i<1000;i++);


        readBuffer =  *sarDataRegister;

        /* Read the ADC data continously 40 times */
        while((readBuffer & 0x8000) == 0x1000)
        {
            readBuffer =  *sarDataRegister;    
        }
       
        // Extract the converted data (clear other flags).
        readBuffer = readBuffer & 0x3FF;
        
        x--;
    
    }

    CSL_SAR_REGS->SARPINCTRL = 0;

  • Hi Sasha,

    We have identified an error in the SAR documentation that keeps Channel 2 disabled and unable to read the voltage on the pin. We will fix the documentation soon.

    Before I mention the method to enable Channel 2, it is strongly recommended to use Channel 0 and 1 to do battery measurements as the voltage divider (by a factor of 8) on it helps protect the device from excess current flowing into it. If you use Channel 2, there is a possibility of damaging the device. Please see section 2.4 of the SAR User's Guide (sprufp1a.pdf).

    To enable Channel 2, you would need to set bit 2 of the SARPINCTRL register (which is mentioned as Reserved in documentation).

    Regards,

    Sunil

  • Hi,

     We are also using C5515. We are applying a 1.04V input to GPAIN0. Its a divided voltage from a battery of 4.2V (Divider resistances of 10k and 3.3k).

    Now as you mentioned we enabled Channel 2 by setting the reserved bit. My reference voltage set to 1.3V . I am getting a voltage value of 0.89V ie a count of 704 . When I measure the input pin voltage it is 1.041V.

    I even tried setting the multichannel mode from normal mode. Even then the result is the same . Its a 30% error. How to over come this where am I making the error

    SAR_PINCTRL = 0x3104;

    SAR_CTRL = 0xAC00;

    while (SAR_DATA & ADC_BUSY);

    Sar = SAR_DATA;

    SAR_PINCTRL = 0x3104;

    return (Sar & 0x3ff);