Hot!Read Device Information Area (DIA) PIC16F19176

Author
MarcelC
Starting Member
  • Total Posts : 34
  • Reward points : 0
  • Joined: 2018/08/31 05:01:52
  • Location: Germany
  • Status: offline
2019/03/19 05:08:34 (permalink)
0

Read Device Information Area (DIA) PIC16F19176

Hallo,
I try to read the calibration Values out of the DIA but i get only the Value 0x3FF no matter which register is selected.
I use the following code:
NVMCON1bits.NVMREGS = 0x01;
NVMADRL = 0x19;
NVMADRH = 0x81;
NVMCON1bits.RD = 0x01;
while (NVMCON1bits.RD == 1);
FVR_read1 = NVMDATL;
FVR_read2 = NVMDATH;

 
Maybe someone has an Idea ?!?
#1

15 Replies Related Threads

    coffee critic
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/19 10:36:01 (permalink)
    0
    Add this line between the NVMADRH line and the NVMCON1bits.RD line.
     
    NVMCON1bits.NVMREGS = 0;
     
    Let me know if this works. 
     

    n_*$
    #2
    jack@kksound
    code tags!
    • Total Posts : 3178
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/19 11:04:14 (permalink)
    0
    coffee critic
    Add this line between the NVMADRH line and the NVMCON1bits.RD line.
     
    NVMCON1bits.NVMREGS = 0;
     
    Let me know if this works. 
     


    Does that not set the NVM access to the FLASH (PFM) memory instead of the DIA memory?
    Datasheet:

    bit 6 NVMREGS: Configuration Select bit
    1 = Access EEPROM, DIA, DCI, Configuration, User ID and Device ID Registers
    0 = Access PFM

    #3
    coffee critic
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/19 12:44:36 (permalink)
    0
    I modified some MCC code a year ago for the 16F15355 to allow me to read the DIA90 value for temperature calibration.  This line is the only difference from the standard MCC FLASH_ReadWord call. 
     
    That's why I asked to confirm if this works. If not I would compare the 16F19176 with the 15355 to see if there were any other differences in NVM modules.  

    n_*$
    #4
    jack@kksound
    code tags!
    • Total Posts : 3178
    • Reward points : 0
    • Joined: 2014/05/14 10:03:19
    • Location: 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/19 13:28:50 (permalink)
    +1 (1)
    @MarcelC;
    possibly if you post your complete and actual program code then maybe an error elsewhere will become apparent.
    #5
    MarcelC
    Starting Member
    • Total Posts : 34
    • Reward points : 0
    • Joined: 2018/08/31 05:01:52
    • Location: Germany
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/20 00:09:43 (permalink)
    0
    coffee critic
    Add this line between the NVMADRH line and the NVMCON1bits.RD line.
     
    NVMCON1bits.NVMREGS = 0;
     
    Let me know if this works. 
     


    No, it wont work. I think it will read in PFM. Because i get other values but they make no sense.....
     
    But i have read out the DIA by using my debugger (see attached picture) and see, in 8119h the data is 0x3FF so the readout will work!
    But why there is 0x3FF ???? Someone an Idea?
     
    I try different (2Pcs) devices there are always 0x3FF
    post edited by MarcelC - 2019/03/20 00:27:06

    Attached Image(s)

    #6
    coffee critic
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/20 08:42:28 (permalink)
    0
    If I get a chance today, I will try to generate some MCC code for one of the 16F191XX parts and readout all the DIA locations via UART.  I will let you know what I find.  There shouldn't be much difference between the 16F19176 and the 16F15355.  The fact that all the DIA constants for the FVR are wrong is a pointer.   

    n_*$
    #7
    coffee critic
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/20 10:28:43 (permalink)
    0
    The good news is that my DIA read routine works.  The temp indicator cal values are printing. 
     
    The bad news is that I am getting the same results for the FVR readings as you are seeing in the debugger.  The FVR values should be the measured buffer voltage in mV.   
     
    TSLR2 =, 1415
    TSHR2 =, 2096
    FVRA1X =, 16383
    FVRA2X =, 16383
    FVRA4X =, 16383
    FVRC1X =, 16383
    FVRC2X =, 16383
    FVRC4X =, 16383
     
    I will dig into this some more and see what I find.

    n_*$
    #8
    coffee critic
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/21 11:11:20 (permalink)
    0
    I tested a newer A3 part.  The DIA has the FVR information.  I would suggest putting in a support ticket. 
    TSLR2 =, 1610
    TSHR2 =, 2409
    FVRA1X =, 1022
    FVRA2X =, 2040
    FVRA4X =, 4088
    FVRC1X =, 1021
    FVRC2X =, 2045
    FVRC4X =, 4088

    n_*$
    #9
    JPortici
    Super Member
    • Total Posts : 623
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/21 12:54:18 (permalink)
    0
    I wonder... does a pointer to __rom and/or const work?
     
    I may be able to check with a PIC16F18855 (if i find where i put the MPLAB XPRESS board..)
     
    I checked, it doesn't.
    It does work on PIC18 though...
    post edited by JPortici - 2019/03/21 13:44:34
    #10
    coffee critic
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/21 14:21:52 (permalink)
    0
    That would be good to know.  All these locations are defined in device specific header for example DIA_TSLR2.  I have the hood open if you want to give me a line of code to test.  

    n_*$
    #11
    JPortici
    Super Member
    • Total Posts : 623
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/22 00:49:28 (permalink)
    0
    If you want to test
     
    This code works for PIC18, K42 series
    uint16_t read_flash_loc(__uint24 address) {
      uint16_t const *progmem_ptr;
      address &= 0xFFFFFE;
      progmem_ptr = (uint16_t const *) address;
      return *progmem_ptr;
    }

     
    This function will read a memory location at any address of the program memory space, including configuration space and will generate table read instructions.
    note the "const", as the __rom qualifier will generate what i think is incorrect code (the pointer address size is 16 bit instead of 24 bits for PIC18 of up to 64k of program memory. Basically it produces slightly faster code as the upper byte is discarded but you can't reach configuration space. for 128k devices the size is 24 bits. I already opened a ticket for this..)
    const will make the pointer address the whole memory space.
     
    This should work with a newer PIC16 too as the 16F19176 and the 16F18855.
    I have both (Mplab XPRESS board and the 19176 explorer board, the one with the big-ass LCD) but i only tried on the XPRESS.
     
    it DOES read the flash memory, but apparently it doesn't read the configuration space (I tried to read the the device ID but it returned uncorrelated data). I haven't spent too much time on it though.. will make more meaningful tests during the weekend
    #12
    qhb
    Superb Member
    • Total Posts : 9684
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: online
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/22 01:13:13 (permalink)
    0
    Jack_M
    ..
    This should work with a newer PIC16 too as the 16F19176 and the 16F18855.

    I doubt it.
    The compiler will be using the FSRx/INDFx registers to read the memory, and they cannot access the configuration space, it can only be done via the NVM registers.
     
    #13
    JPortici
    Super Member
    • Total Posts : 623
    • Reward points : 0
    • Joined: 2012/11/17 06:27:45
    • Location: Grappaland
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/22 01:36:14 (permalink)
    0
    I admit I haven't checked the compiler output, but you may be right. In fact i haven't tried with the debugger also because i didn't have my soldering iron at hand to solder the programming header on the demo boards. Which is why i said i'll make more meaningful tests over the weekend :)
    #14
    coffee critic
    Super Member
    • Total Posts : 350
    • Reward points : 0
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/22 08:57:19 (permalink)
    0
    That line returns 0x3FFF so it must not be selecting configuration space.

    n_*$
    #15
    MarcelC
    Starting Member
    • Total Posts : 34
    • Reward points : 0
    • Joined: 2018/08/31 05:01:52
    • Location: Germany
    • Status: offline
    Re: Read Device Information Area (DIA) PIC16F19176 2019/03/25 23:22:57 (permalink)
    +1 (1)
    I use the following code :
     
    uint16_t read_DIA (uint16_t Add)
    {
        NVMCON1bits.NVMREGS = 0x01;
        NVMADRH = ((Add >> 8) & 0xFF);
        NVMADRL = (Add & 0xFF);
        NVMCON1bits.RD = 0x01;
        while (NVMCON1bits.RD == 1);
        return ((NVMDATH<<8)+NVMDATL);
    }

     
    And this code returns exatly the same values which I get when I read the DIA with my PicKit3 in MPLABX.
    I also opend a case at the microchip support, because I think there is something wrong with the DIA values .......
    #16
    Jump to:
    © 2019 APG vNext Commercial Version 4.5