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.

AM2634: ADC + PBB Problems reading correct values from the PPB-Result Registers

Part Number: AM2634

Hi,

In an example program derived from the TI example I want to digitize a sine wave (10KHz) generated by a function generator and use an ISR to update the DAC port. It works without problems as long as I do not substract in one of the PPB an offset from the ADCRESULT register. If I configure for example PPB1 to subtract a value of '1' instead of zero I don't get any DAC port updates anymore. If I leave the value to be subtracted '0' it works as before. If I stop the program and dump the registers using the memory view I see the subtract operation is working correctly. The RESULT register of the PPB1 has the correct value.

Q: What do I need to make or add in the configuration to get this working?

Below is the code of the ISR. I don't change the code at all. The only thing I do is in the syscfg tool changing the offset value from '0' to '1' or to any other value. It doesn't matter. As long as the configured offset is not '0' I get no outputs. I did 'point' the remaining 3 PPB's to another SOC which is not active. This is done just tot make sure the PPB1 operation on SOC0, that is the one I use, is not disturbed by PPB2..PPB4.

ISR-Code

// ISR to update the DAC
static void App_adcISR(void *args) {

    if (gLoopCnt) gLoopCnt--;

    /*
     * I tried to read the PPB1 result register in the ISR. However for some kind of reasons it
     * doesn't work reliable.
     *
     * If I 'subtract' '0' from the ADC0Result in the PP1 and use the PPB1 Result Register the program
     * works. If I correct any other value than '0' from the ADC0Result Register then no output on
     * the DAC port ? For example if I subtract a value of '1' (no 2complement!) I can see the result
     * of the subtraction using the memory view window that the subtraction takes place. However the
     * DAC port remains silent ?!
     */
    // uint16_t ui16ADC0Result = ADC_readResult(CSL_CONTROLSS_ADC0_RESULT_U_BASE, ADC_SOC_NUMBER0);
    uint16_t ui16ADC0PPB1Result = (uint16_t) ADC_readPPBResult(CSL_CONTROLSS_ADC0_RESULT_U_BASE, ADC_PPB_NUMBER1);

    /*
    if (ui16ADC0Result > 2047) {
        ui16ADC0Result = 2047 - (ui16ADC0Result - 2047);
    } else if (ui16ADC0Result < 2047) {
        ui16ADC0Result = 2047 + (2047 - ui16ADC0Result);
    }
    */

    // Read the ADC Value and push it to the DAC output
    DAC_setShadowValue(CONFIG_DAC0_BASE_ADDR, ui16ADC0PPB1Result);

    // Check if overflow has occurred
    if(true == ADC_getInterruptOverflowStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1))
    {
        ADC_clearInterruptOverflowStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1);
        ADC_clearInterruptStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1);
        gISROverflow++;
    } else {
        /* Clear any pending interrupts */
        ADC_clearInterruptStatus(CONFIG_ADC0_BASE_ADDR, ADC_INT_NUMBER1);
    }
}

A scope- shot when the value to be subtracted is '0'.

  • Hi 

    I am looking into the code trying to reproduce your issue at my end. Will get back to you soon.

    Regards

    Sri Vidya

  • Hi

    Could you Confirm which example are you using? Is it examples/drivers/adc/adc_ppb_epwm_trip/ ?

    Regards

    Sri Vidya

  • Hi Sri Vidya,

    my example is based on ADC SOC software. I did attach the archive. You need to feed in a signal from a generator and you can capture the output on the DAC port.

    br

    Markus

    AM2634-ADC2DAC_ISR-20220726_001.zip

  • Hi Markus

    I have taken your project and imported into CCS. I have changed my PPB1 reference offset to 100.

    I have left my Analog pin open and tried to see the ADC result and ADC PPB result values in the watch window. Here ui16ADC0Result and ui16ADC0PPB1Result are made global.


    static void App_adcISR(void *args) {

    if (gLoopCnt){

    gLoopCnt--;}
    ui16ADC0Result = ADC_readResult(CSL_CONTROLSS_ADC0_RESULT_U_BASE, ADC_SOC_NUMBER0);
    ui16ADC0PPB1Result = (uint16_t) ADC_readPPBResult(CSL_CONTROLSS_ADC0_RESULT_U_BASE, ADC_PPB_NUMBER1);

    I am able to see the PPB1 result as 100 difference with the ADC. It is working.

    Regards

    Sri Vidya

  • Hi Sri Vidya,

    I was able to further track down the root cause of the DAC port being stuck. What you are observing is correct. However in the DAC write function there is a check (DebugP assertion) in case the value is more (0x0FFFU). And as you might know the the example is writing within the ISR which should be avoided acc. to the DebugP comment section.

    If the input signal is close to 0 the the reference offset computation within one of the PPB's can become negative. If for example 0 - 1 is executed '0' being the ADC value and '1' being the value to be subtracted from the ADCResult register, the resulting value will be 0xFFFF. Writing this value to the DAC port using the library function will assert DebugP within the ISR which will finally crash the system ...

    That's why subtracting '0' did not do any harm and subtracting '1' did crash the system. So far so good.

    It points me to another problem. If I really want to use the offset correction I have to use the "PPBx Calibration Offset". This works as expected. Both the lower limit and higher limit of the ADC's conversion range is checked. There are no 'negative' numbers.

    But if I want to use the "PPBx Reference Offset" the numbers may become negative.  Therefore if I use this function I have to check for negativ numbers not being possible in the ADC0Result register but in the PPBx result registers 1.

    Using the DAC-Port example above. It looks like this for the PPBx Result Register 1. The negative numbers create a 'jump'. I know it can be explained. However I would have wished an option could be used to limit the low end of the result register 1 value as well. The way it is now, I will need additional SW to check for negative numbers in case I use this PPBx function. This can become tricky if speed is everthing.

    Thank's for your support. Case closed.

    Markus