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 TivaWare/driverlib/adc.c? (ADCIntUnregister)

Hi,

I'm looking at the ADC module, and when checking what the driverlib functions actually do, I stumbled across this thing that I think is a bug. It seems that the (internal to the driverlib) function _ADCIntNumberGet always returns the interrupt number from ADC0:

static uint_fast8_t
_ADCIntNumberGet(uint32_t ui32Base, uint32_t ui32SequenceNum)
{
    uint_fast8_t ui8Int;

    //
    // Determine the interrupt to register based on the sequence number.
    //
    if(CLASS_IS_BLIZZARD)
    {
        ui8Int = ((ui32Base == ADC0_BASE) ?
                  (INT_ADC0SS0_BLIZZARD + ui32SequenceNum) :
                  (INT_ADC0SS0_BLIZZARD + ui32SequenceNum));
                   ^^^^^^^^^^^^^^^^^^^^
    }
    else
    {
        ui8Int = 0;
    }

    return(ui8Int);
}

Shouldn't the caret-marked constant be INT_ADC1SS0_BLIZZARD instead?

Interestingly, that function is only used once, in ADCIntUnregister. In ADCIntRegister, where similar functionality is required, it is provided inline, without a call to _ADCIntNumberGet. In ADCIntRegister, the alternative result of the ternary operator has INT_ADC1SS0_BLIZZARD, as is expected.

I'm looking at TivaWare version 1.1.

Best,

Veikko

  • Veikko Immonen said:
    Shouldn't the caret-marked constant be INT_ADC1SS0_BLIZZARD instead?

    From looking at the code agree.
    Veikko Immonen said:
    I'm looking at TivaWare version 1.1
    This appears to a bug introduced by TivaWare, since StellarisWare version 9453 doesn't have this bug.

     In StellarisWare there is no _ADCIntNumberGet function and both ADCIntRegister and ADCIntUnregister use 

        //
        // Determine the interrupt to unregister based on the sequence number.
        //
        ulInt = ((ulBase == ADC0_BASE) ? (INT_ADC0SS0 + ulSequenceNum) :
                 (INT_ADC1SS0 + ulSequenceNum));
    
  • Okay, now I've got to say I'm puzzled and disappointed. This bug has escalated, it now affects also ADCIntRegister, in the newest revision of TivaWare (2.1.0.12573).

    ADCIntRegister too now calls _ADCIntNumberGet, as can be seen in the excerpt below:

    void
    ADCIntRegister(uint32_t ui32Base, uint32_t ui32SequenceNum,
                   void (*pfnHandler)(void))
    {
        uint_fast8_t ui8Int;
    
        //
        // Check the arguments.
        //
        ASSERT((ui32Base == ADC0_BASE) || (ui32Base == ADC1_BASE));
        ASSERT(ui32SequenceNum < 4);
    
        //
        // Determine the interrupt to register based on the sequence number.
        //
        ui8Int = _ADCIntNumberGet(ui32Base, ui32SequenceNum);
        ASSERT(ui8Int != 0);
    
        //
        // Register the interrupt handler.
        //
        IntRegister(ui8Int, pfnHandler);
    
        //
        // Enable the timer interrupt.
        //
        IntEnable(ui8Int);
    }

    _ADCIntNumberGet has been updated with new labels since my last post, but unfortunately the bug has not been corrected:

    static uint_fast8_t
    _ADCIntNumberGet(uint32_t ui32Base, uint32_t ui32SequenceNum)
    {
        uint_fast8_t ui8Int;
    
        //
        // Determine the interrupt to register based on the sequence number.
        //
        if(CLASS_IS_TM4C123)
        {
            ui8Int = ((ui32Base == ADC0_BASE) ?
                      (INT_ADC0SS0_TM4C123 + ui32SequenceNum) :
                      (INT_ADC0SS0_TM4C123 + ui32SequenceNum)); // <-- problem!
        }
        else if(CLASS_IS_TM4C129)
        {
            ui8Int = ((ui32Base == ADC0_BASE) ?
                      (INT_ADC0SS0_TM4C129 + ui32SequenceNum) :
                      (INT_ADC1SS0_TM4C129 + ui32SequenceNum));
        }
        else
        {
            ui8Int = 0;
        }
    
        return(ui8Int);
    }

    Interestingly enough, the added code for the 129 series is correct. Not much proofreading done there?

    I'd hope someone from the TivaWare team would care to comment. I've just spent a day debugging my uDMA-enabled ADC code that works perfectly fine with ADC0 but hangs in the interrupt handler when using ADC1 - no wonder anymore!

  • Agree, some  more direct feedback from TI and preferably a member of TivaWare team would be appreciated.

  • Hello Veikko,

    I can confirm the issue (was raised in the forum a couple of months back) and this has been marked for fixing in the next TivaWare release.

    Regards

    Amit

  • Thanks Amit, good to know.

  • Good to know bug reports get through :D