• AVR Freaks

Hot!Improvement idea on BusyADC10() of PIC32 ADC peripheral library

Starting Member
  • Total Posts : 76
  • Reward points : 0
  • Joined: 2011/01/20 03:46:42
  • Location: Switzerland
  • Status: offline
2011/08/15 03:19:04 (permalink)

Improvement idea on BusyADC10() of PIC32 ADC peripheral library

Currently, BusyADC10 looks like this in the PIC32 C Compilers v2.00's ADC peripheral library:

#define BusyADC10() (AD1CON1bits.DONE)

I think the semantics are inverted and it does not capture when the ADC is during acquisition. How about the following?

#define BusyADC10() (!AD1CON1bits.DONE || AD1CON1bits.SAMP)

It captures acquisition and conversion times.

1 Reply Related Threads

    New Member
    • Total Posts : 22
    • Reward points : 0
    • Joined: 2014/11/27 01:18:29
    • Location: 0
    • Status: offline
    Re: Improvement idea on BusyADC10() of PIC32 ADC peripheral library 2019/11/14 02:55:58 (permalink)
    +1 (1)
    I encountered the same problem.
    This macro should be inverted.
    #define BusyADC10() (AD1CON1bits.DONE)

    #define BusyADC10() (!AD1CON1bits.DONE)

    According to the "PIC32 Peripheral Libraries for MPLAB C32 Compiler" documentation:
    This macro returns the ADC conversion status.
    Return Value:
    ‘1’ if ADC is busy in conversion.
    ‘0’ if ADC is has completed conversion or currently not performing any
    Code Example: while(BusyADC10());

    But according to the ADC Family Reference Manual (DS61104E):
    DONE: Analog-to-Digital Conversion Status bit(2)
    1 = Analog-to-digital conversion is done
    0 = Analog-to-digital conversion is not done or has not started
    Clearing this bit will not affect any operation in progress.

    Jump to:
    © 2020 APG vNext Commercial Version 4.5