• AVR Freaks

Hot!Pic24fj64gb202 use adc module with spi module.

Author
TER
New Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2019/04/15 03:59:38
  • Location: 0
  • Status: offline
2020/03/06 04:13:04 (permalink)
0

Pic24fj64gb202 use adc module with spi module.

I configured the ADC and SPI modules in pic24fj64gb202. Both work normaly, but when I send and receive data from the SPI DI/DO ports, a voltage appears on the analog contact I'm listening. How to configure ADC and SPI registers correctly to solve this problem?
#1

8 Replies Related Threads

    LdB_ECM
    Super Member
    • Total Posts : 406
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/03/06 05:44:56 (permalink)
    5 (1)
    You do not have enough drive and you are seeing sample and hold noise. FIGURE 25-3 on page 368 on the datasheet shows you the analog model and typically you have to bank you are driving a 3K load.
     
    That datasheet on that part is truely horrible and cut down and only because I know this one pull this datasheet
    http://ww1.microchip.com/downloads/en/DeviceDoc/PIC24FJ256GA705-Family-Data-Sheet-DS30010118D.pdf
     
    It has a section called "24.4 Achieving Maximum A/D Converter Performance" on page 291.
    It gives you the whole story about working out a good sample time for an given input impedance and gives you a worked example.  You will need to use the values from Pic24fj64gb202 datasheet but its the same setup on the ADC.
     
    The only way you can make the problem go away and ignore it is basically have a amplifier with an output impedance less than 50ohm right in front of the ADC which is stated on the datasheets as  "Keeping RS < 50ohms is recommenced for best results."   .... I love recommenced :-)
     
    Your part datasheet also doesn't tell you the other important thing when to turn the charge pump on the ADC. It's given in the 705 datasheet "If the AVDD supply is < 2.7V, the Charge Pump Enable bit (PUMPEN)"  on your part its bit13 AD1CON3 but no discussion of what it is and when you should turn it on which is rather funny.
     
    I have to say they took a few shortcuts with that datasheet and no wonder you were confused.
    #2
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/03/07 18:53:45 (permalink)
    4 (1)
    As above.
    Also, on your PCB, pay CLOSE attention to ground return paths for both your SPI circuit and your analog circuit

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #3
    TER
    New Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2019/04/15 03:59:38
    • Location: 0
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/03/11 00:27:35 (permalink)
    0
    Thank you very much for your answers! Ric you can't give me advice or article on this topic. How can I close the ground connections?  I tried some options, but I'm not sure that I doing everything right.
    #4
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/03/11 05:06:37 (permalink)
    4 (1)
    What is your background?
    i.e. have you studied any electronic engineering?
    As I said, you have to think about what path the ground return for each of your inputs and outputs is taking, and make sure your ADC inputs aren't seeing ground noise cause by heavier currents in other circuits.
     

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #5
    LdB_ECM
    Super Member
    • Total Posts : 406
    • Reward points : 0
    • Joined: 2019/04/16 22:01:25
    • Location: 0
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/03/11 06:35:11 (permalink)
    5 (1)
    TER you obviously have a oscilloscope so can you give us images of the noise on the AVdd pin, Vdd pin and Vdd core to a ground as close as you can to those pins and finally an image of the analog line and a basic description of how the analog gets there like thru op amps etc?.
     
    There are multiple issues that could be at play and we actually need to see the signals other than that all you can do is generically cover it like Ric did. To make it clear there are multiple voltages and paths even in the PIC and we need to work out which section the noise is on.
    post edited by LdB_ECM - 2020/03/11 06:36:46
    #6
    LamdaElectronics
    Assembly_For_Ever
    • Total Posts : 81
    • Reward points : 0
    • Joined: 2010/07/23 04:04:41
    • Location: Hellas-Greece
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/05/01 03:17:50 (permalink)
    3 (1)
    As it seems you have noise problems caused by the μC itself. 
    Adding to the previous suggestions, I would propose to use a capacitor from the ADC pin (as close as possible to the μC) to the ground. 
    #7
    Shamzclt
    New Member
    • Total Posts : 4
    • Reward points : 0
    • Joined: 2020/03/01 11:39:13
    • Location: 0
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/06/23 23:50:44 (permalink)
    0
    Hi All..
    I am working with the same controller PIC24fj64gb202 for a datalogger application. So far it goes well until i tried to configure ADC. I Tried to simulate ADC in mplabx IDE, with xc16 compiler, it is not giving converted output. Always showing '0'. I am pasting my settings and routine here.
     
            AD1CON2bits.PVCFG = 0x00 ;
            AD1CON2bits.NVCFG0 = 0x0 ;
            AD1CON3bits.ADCS = 0xFF;
            AD1CON1bits.SSRC = 0x0;
            AD1CON3bits.SAMC = 0b10000;
            AD1CON1bits.FORM = 0b00;
            AD1CON2bits.SMPI = 0x0;
            AD1CON1bits.ASAM=0;
            AD1CON1bits.MODE12 = 0 ;
            AD1CON1bits.ADON = 1;
    ---------------------------------------------------
     
       AD1CHS = channel ;
       
        // Get an ADC sample
        AD1CON1bits.SAMP = 1;           //Start sampling
        
              
       for(i=0;i<1000;i++)
        {
            Nop(); //Sample delay, conversion start automatically
        }

        AD1CON1bits.SAMP = 0;           //Start sampling
        for(i=0;i<1000;i++)
        {
            Nop(); //Sample delay, conversion start automatically
        }

        while(!AD1CON1bits.DONE);       //Wait for conversion to complete

        return ADC1BUF0;
     
    ------------------------------------------
     
    I have been working on the same for 3 days. Please someone help
    #8
    ric
    Super Member
    • Total Posts : 28009
    • Reward points : 0
    • Joined: 2003/11/07 12:41:26
    • Location: Australia, Melbourne
    • Status: offline
    Re: Pic24fj64gb202 use adc module with spi module. 2020/06/23 23:59:20 (permalink)
    0
    Please don't hijack someone else's topic, start your own.
    (and not in this "programming specifications" sub-forum. That is for ICSP programming, not general programming questions)

    I also post at: PicForum
    Links to useful PIC information: http://picforum.ric323.co...opic.php?f=59&t=15
    NEW USERS: Posting images, links and code - workaround for restrictions.
    To get a useful answer, always state which PIC you are using!
    #9
    Jump to:
    © 2020 APG vNext Commercial Version 4.5