• AVR Freaks

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

Author
rauhfasertapete
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)
0

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

1 Reply Related Threads

    ThierryV
    New Member
    • Total Posts : 13
    • 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.
     
    Original:
    #define BusyADC10() (AD1CON1bits.DONE)

    Working:
    #define BusyADC10() (!AD1CON1bits.DONE)

     
    According to the "PIC32 Peripheral Libraries for MPLAB C32 Compiler" documentation:
     
    BusyADC10:
    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
    conversion.
    Code Example: while(BusyADC10());

     
    But according to the ADC Family Reference Manual (DS61104E):
    AD1CON1:bit0:
    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.

     
    #2
    Jump to:
    © 2019 APG vNext Commercial Version 4.5