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.

Bug in PDK 3.0 Touch-Screen Controller Driver TSCADCStepFifoConfig() function

Hello.

I'm using PDK 3.0 (c:\ti\pdk_am335x_1_0_3) (with its own version of Starterware).

In the file:  <pdk>\packages\ti\starterware\dal\tsc_adc_ss.c

is the function  TSCADCStepFifoConfig().

Inside that function is this code:

    /* Configure the Fifo. */
    HW_WR_FIELD32((baseAddr + ADC0_STEPCONFIG(stepNum - 1)),
                   ADC0_STEPCONFIG_FIFO_SELECT,
                   fifoSel);

    if (TRUE == enableIrq)
    {
        /* Enable IRQ request. */
        HW_WR_FIELD32((baseAddr + ADC0_FIFOTHR(fifoSel - 1)),
                       ADC0_FIFOTHR_FIFO_THR_LEVEL,
                       (sampleLvl - 1));
    }
    else
    {
        /* Enable DMA request. */
        HW_WR_FIELD32((baseAddr + ADC0_DMAREQ(fifoSel - 1)),
                       ADC0_DMAREQ_DMA_REQUEST_LEVEL,
                       (sampleLvl - 1));
    }

If you will look carefully, the first action  HW_WR_FIELD32()  uses the argument  'fifoSel'  variable and expects the value 0 or 1 to be passed to represent TSC_ADC_SS output FIFO0 or FIFO1 respectively.  This value gets written into each  STEPCONFIGx  register's  FIFO_select field which clearly has to contain the value 0 or 1, as it is a single bit.

However, down in the IF block, if you look carefully, you can see that both the  ADC0_FIFOTHR(m)  and  ADC0_DMAREQ(m)  macros are designed to take argument  'm'  values of either 0 or 1.  However, instead, they are being both being fed with  'fifoSel - 1'.  Thus, if  fifoSel == 0, then the computed address is an ugly random error, and if  fifoSel == 1, then the  FIFO0THRESHOLD (wrong register)  FIFO1_threshold_Level  field is written with the  passed threshold level (sampleLvl), and in THAT case, subtracting 1 from that value is correct.  But it goes to the wrong register!

This conflict makes it makes it impossible to use this function and cause the intended effect.  The corrected code should remove  subtracting 1 from the 'fifoSel' variable in both cases in the IF block, like this:

    if (TRUE == enableIrq)
    {
        /* Enable IRQ request. */
        HW_WR_FIELD32((baseAddr + ADC0_FIFOTHR(fifoSel)),
                       ADC0_FIFOTHR_FIFO_THR_LEVEL,
                       (sampleLvl - 1));
    }
    else
    {
        /* Enable DMA request. */
        HW_WR_FIELD32((baseAddr + ADC0_DMAREQ(fifoSel)),
                       ADC0_DMAREQ_DMA_REQUEST_LEVEL,
                       (sampleLvl - 1));
    }

That will make the intended values go into the intended register fields.

Kind regards,
Vic