• AVR Freaks

Why ADCANCONbits.WKRDY0 remains at zero (Example 22-1, ADC and PIC32MZ)

Author
DominusT
Super Member
  • Total Posts : 1401
  • Reward points : 0
  • Joined: 2005/07/22 08:31:18
  • Status: offline
2020/06/30 07:59:29 (permalink)
0

Why ADCANCONbits.WKRDY0 remains at zero (Example 22-1, ADC and PIC32MZ)


Hi.
I'm trying to make a simple example of reading with the ADC of the PIC32MZ2048EFM100 device with the AN0 terminal.
 
I'm taking example 22-1 (Initializing and Using ADC Class 1 Input) from section 22. (I don't want to use Harmony)
 
In the following link someone does a more detailed analysis of the example:

https://www.aidanmocke.com/blog/2019/09/12/adc/
 
I'm debugging my project until the next part of the code is reached:

while(!ADCANCONbits.WKRDY0);

and the WKRDY0 bit stays at zero without ever changing to 1.
 
Searching the forum, I found someone with a very similar problem:

https://www.microchip.com/forums/m1018963.aspx
 

But there seems to be nothing useful regarding the example I am implementing.
 
Any ideas what I may be doing wrong?
 
 
 
 
#1

4 Replies Related Threads

    DominusT
    Super Member
    • Total Posts : 1401
    • Reward points : 0
    • Joined: 2005/07/22 08:31:18
    • Status: offline
    Re: Why ADCANCONbits.WKRDY0 remains at zero (Example 22-1, ADC and PIC32MZ) 2020/06/30 11:18:48 (permalink)
    2 (1)
    I have given up.

    After trying several examples from the forum that none worked, I decided to try it on Harmony and voila.

    It took me just 10 minutes to understand and perform a simple example.
    #2
    WaltR
    Super Member
    • Total Posts : 3812
    • Reward points : 0
    • Joined: 2003/11/07 12:38:21
    • Status: offline
    Re: Why ADCANCONbits.WKRDY0 remains at zero (Example 22-1, ADC and PIC32MZ) 2020/07/01 12:10:12 (permalink)
    4 (1)
    The Example 22-1 code is highly suspect that it is NOT real tested code. Why?
    This line should not have Main() input parameters or ever return in PIC imbedded C:
    int main(int argc, char** argv){
    .....
    return (1);
    }

     
    One thing I see missing in same example code is READING the ADC data before starting a new conversion.
    Check the example code against the Harmony code to see if ADC data read is done after initialization of the ADC.
     
    You do not state how you want to use the ADC...seems you want a Manual conversion.
    I wrote up how to do that here:
    https://www.microchip.com/forums/m1131153.aspx
     
    #3
    DominusT
    Super Member
    • Total Posts : 1401
    • Reward points : 0
    • Joined: 2005/07/22 08:31:18
    • Status: offline
    Re: Why ADCANCONbits.WKRDY0 remains at zero (Example 22-1, ADC and PIC32MZ) 2020/07/01 12:25:07 (permalink)
    0
    WaltR
    The Example 22-1 code is highly suspect that it is NOT real tested code. Why?
    This line should not have Main() input parameters or ever return in PIC imbedded C:
    int main(int argc, char** argv){
     
    .....
     
    return (1);
    }
     

     
    One thing I see missing in same example code is READING the ADC data before starting a new conversion.
    Check the example code against the Harmony code to see if ADC data read is done after initialization of the ADC.
     
    You do not state how you want to use the ADC...seems you want a Manual conversion.
    I wrote up how to do that here:
    https://www.microchip.com/forums/m1131153.aspx
     


    Thanks for answering.
    It seems to me that I did try your example when I was looking for information in the forum, but the code always reaches only this line and does not advance to the next:
    while (! ADCANCONbits.WKRDY0);

    What I was thinking was to analyze how Harmony configured the ADC module registers to identify any difference, but I am very busy with the project, so in the next few days I will analyze what the difference is.
    #4
    WaltR
    Super Member
    • Total Posts : 3812
    • Reward points : 0
    • Joined: 2003/11/07 12:38:21
    • Status: offline
    Re: Why ADCANCONbits.WKRDY0 remains at zero (Example 22-1, ADC and PIC32MZ) 2020/07/01 18:04:26 (permalink)
    0
    Ok. I would like to hear/see what you find.
     
    Oh this thing has too many bits.
    Thought that was the ready to read data but now see it is the the ADC Ready (clocks and analog circuits ready).
     
    I see my my working code a UART debug output "Clock ON" so I think I had a issue to debug when first setting up the ADCs. Don't remember what the issue was but it did take a while to get the ADCs to work.
     
    #5
    Jump to:
    © 2020 APG vNext Commercial Version 4.5