FVR ADC issue - PIC16F18854

Author
jc999
Starting Member
  • Total Posts : 13
  • Reward points : 0
  • Joined: 2017/10/08 07:23:13
  • Location: 0
  • Status: offline
2017/11/12 04:06:42 (permalink)
0

FVR ADC issue - PIC16F18854

Hi All,
I am using a PIC16F18854 with a stable VDD of 5.0V
Code has been primarily generated using MCC and verified with the datasheet.

Applicable registers:
ADREF: ADNREF = VSS, ADPREF = FVR_buf1
FVRCON: ADFVR = 4x, FVREN = enabled

This does not seem to work correctly. The ADC range appears to be VSS-VDD; changing VDD affects the ADC output. It appears the reference is not stable and the ADC acts as if it is being referenced to VDD (between 4.75V-6V).

However, changing just one bit of FVRCON to select to 2x works as expected - a reference 2.048V. The output is stable when varying the supply voltage.

Is there anything I have missed here? Or a possible bug with the chip/compiler?

Any ideas appreciated.

Kind regards,
JC
#1

9 Replies Related Threads

    jc999
    Starting Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: FVR ADC issue - PIC16F18854 2017/11/13 11:39:53 (permalink)
    +1 (1)
    It's because I thought my first post disappeared but it turns out it was Microchip hadn't approved my posts.
     
    The issue is solved now. The MPCC function ADCC_StartConversion sets the channel then immediately flags the ADC to start a conversion without a delay, despite the numerous times it stated in the datasheet to wait until the ADC is ready.
     
    I would have thought this was built into the code generator functions but hadn't looked closely enough.
     
    This has happened so many times in harmony, I now see that no matter what code you use from the Microchip libraries or MPCC generated code, you have to go in and verify everything yourself.
    #2
    DarioG
    leaving this planet
    • Total Posts : 53043
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: porcodioland
    • Status: online
    Re: FVR ADC issue - PIC16F18854 2017/11/13 11:41:53 (permalink)
    +1 (1)
    Personally, it looks like PLIB were more trustable than their substitutes - but I have not used the latter much...
     
    In any case, in the end, it's good to check the datasheet, and possibly what values end up into the Registers after calling any type of "high level" function.

    Dario Greggio
    --
    how does it feel, never having been loved? as life fades away, day after day, on this planet made of s h i t...

    #3
    jc999
    Starting Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: FVR ADC issue - PIC16F18854 2017/11/13 11:45:50 (permalink)
    +1 (1)
    Very true. I checked the registers funnily enough but not the higher level function. Well - it's hardly a high level, 2 lines which set 2 registers and even that isn't done right!
     
    I have a habit of writing all the code from scratch and was attempting to make more use of the libraries.
     
    I guess the approach to take is use the datasheet to learn as if you were writing it from scratch, then read through and/or modify the libraries to suit your needs.
     
    I'm an intermediate user and can see where the pain was in learning as a beginner. Getting a post on this forum replicates that perfectly.
    #4
    DarioG
    leaving this planet
    • Total Posts : 53043
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: porcodioland
    • Status: online
    Re: FVR ADC issue - PIC16F18854 2017/11/13 11:56:29 (permalink)
    +1 (1)
    Yeah Smile
    I always was a big lover of libraries, and only seldom I met bugs... or, at times, some unclear parameter that I had to check along with the debugger and the Docs.
     
    But then they were "abstracting". MCC tries to make a "suit-for-you" code and, IMO, fails in creating a "safe environment" that can (ultimately) become bugs-free and widespread.
     
    In the end, I like that Microchip is for "intermediate to experts" Smile compared to Arduino. Of course, this creates pain to beginners... if there was some kind of "Basic interpreter" that fits most PICs, it would be better - for that prupose.

    Dario Greggio
    --
    how does it feel, never having been loved? as life fades away, day after day, on this planet made of s h i t...

    #5
    jc999
    Starting Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: FVR ADC issue - PIC16F18854 2017/11/13 12:15:55 (permalink)
    +1 (1)
    I like it too and have never used actually had the need for Arduino as I have been happy to get an AVR/PIC running quickly.
     
    I started with AVR and found that Atmel Studio is much better software, especially Intellisense. The AVRFreaks forum is great. Plus the programmer seems more reliable, whereas with MPLAB and Pikit 3 it constantly fails to connect/program.
     
    I have been using more Microchip products because of the available range as my knowledge has increased.
     
    The trouble is a lot of the MCC stuff just doesn't work or would never work on any PIC. That's silly; I understand you have to manually change things (it's not supposed to be writing software for you) - but the idea of these abstraction tools isn't to make it beginner friendly, but to simply save time and help prevent bugs at the lowest levels, allowing the programmer not to have to think about "reinventing the wheel" type stuff. That, or when you want a bog standard implementation of a simple timer or ADC without faffing with what random registers might be having an unknown effect.
     
    This is especially true for the 32-bit micros where things can get very complicated without abstraction, yet Harmony is rife is issues. Despite having manually implemented protocols before, it can take more time to implement them in these tools which are designed to save time!
    #6
    DarioG
    leaving this planet
    • Total Posts : 53043
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: porcodioland
    • Status: online
    Re: FVR ADC issue - PIC16F18854 2017/11/13 12:27:24 (permalink)
    0
    I don't usually have troubles with programming - even "spider-circuit" soldered directly on PICs' pins work usually at first run!
    And I find Microchip products quite reliable.
     
    I agree on the "cumbersome" way they tried to deal with complex peripherals...

    Dario Greggio
    --
    how does it feel, never having been loved? as life fades away, day after day, on this planet made of s h i t...

    #7
    jc999
    Starting Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: FVR ADC issue - PIC16F18854 2017/11/13 12:48:23 (permalink)
    +1 (1)
    I have no idea what it could be then with the programming. Multiple devices with different Pickits on different computers can fail constantly for me, even just the bare chip with no use of IOs. I have to unplug and replug constantly.
     
    To be fair, Atmel Studio isn't perfect either with the programmer. I randomly get timeouts which hang the system!
    #8
    DarioG
    leaving this planet
    • Total Posts : 53043
    • Reward points : 0
    • Joined: 2006/02/25 08:58:22
    • Location: porcodioland
    • Status: online
    Re: FVR ADC issue - PIC16F18854 2017/11/13 12:59:10 (permalink)
    0
    I have really had few failures in my 16yrs or so: things that happened rarely to me or to some customers include improper capacitors at power pins, un-washed pcbs, load at ICSP pins (but this one is known), the infamous issue with MCLR and internal oscillator on some PICs (and this is known as well)...
     
    Not all Power pins connected, or missing Capacitor at VCore (if any)
     
    Too much drain at Vdd due to other parts.

    Dario Greggio
    --
    how does it feel, never having been loved? as life fades away, day after day, on this planet made of s h i t...

    #9
    jc999
    Starting Member
    • Total Posts : 13
    • Reward points : 0
    • Joined: 2017/10/08 07:23:13
    • Location: 0
    • Status: offline
    Re: FVR ADC issue - PIC16F18854 2017/11/14 11:36:14 (permalink)
    +1 (1)
    It's possible one of the above is an issue with my programmer, as it occurs with 100nF caps, no load on ICSP pins and plugged directly to USB (no hub). A PIC on a breadboard. It works eventually when it fails, just after many tries.
     
    There are some great tools and ideas. It's just a shame that after so many years worth of development, something that should be simple these days like software handling porting (MPCC still says it will not work properly, and doesn't) are yet to be completed.
    #10
    Jump to:
    © 2017 APG vNext Commercial Version 4.5