Menu

[16F18xxx & 152xx] OPGUI cannot write configuration registers1-5

2025-03-30
2025-05-15
<< < 1 2 3 4 > >> (Page 2 of 4)
  • Alberto Maccioni

    Data is exchanged in packets of 64 bytes, and once the outgoing packet is ready PacketIO(t) sends it and waits t ms before reading the response packet. Actually t is a hint; the function starts to wait a response even earlier, and can wait even more than t if nothing comes. The effective wait time is then printed a T=
    bufferU and bufferI are the two packets.
    In the log you see a parsing of the outgoing commands and their response; every command is acknowledged with an echo, so OK means that it was received
    Sure, 14ms may not be enough.
    You may want to read the source code guide

     
  • Dan Skareda

    Dan Skareda - 2025-04-10

    That Anonymous was me, just not logged in. :-) The more I study the program, the more differences I find from the programming specification. It seems that this family of circuits is really different from the others. But I don't understand PICs very well, so I'll leave that assessment to you. It would be great if you could fix it, the programmer is otherwise great.

     
  • Alberto Maccioni

    Now that I look at it I see that the implementation lacks the payload.
    At first glance it was similar to the picture in the 16F153XX programming spec.
    Everything else is identical.
    Sure, I can fix it adding another instruction and increasing the wait time.

     
    • Dan Skareda

      Dan Skareda - 2025-04-11

      Thank you. I will wait for the new version and then I will try programming all the PIC chips again. I also ordered 16f1503 and 16lf1705, so I have a lot of different PIC chips to try. Anyway, I really, really praise your project, because even the very expensive pickit3 can't program 16f13115, so your project is very useful.

       
  • Alberto Maccioni

    Thank you for reporting the issue.
    Probably I will post a release candidate this weekend in order to try the fixes.

     
    • Dan Skareda

      Dan Skareda - 2025-04-11

      I would like to give you practical advice for the next version - according to Microchip's recommendations, every code should contain configuration register settings. That's probably why you require it in your code. But as an ignorant person (and certainly not just me), if the user doesn't know this requirement, he may get confused and not understand what the programmer is requesting. I didn't understand from this message that the programmer explicitly requires register settings in the code. Can you clarify the message? For example

      Code memory:
      ........
      Can't find CONFIG location (0x8007-0x800B) in code. Add the configuration register settings to the code.
      End
      
       

      Last edit: Dan Skareda 2025-04-11
  • Alberto Maccioni

    Try this, please

     
    👍
    1
    • Dan Skareda

      Dan Skareda - 2025-04-13

      Great! It works. I tried 16f13115 and the chip was programmed and its RA2 led was blinking. :-) Later I will try all the other chips and post a report here.

       
    • Dan Skareda

      Dan Skareda - 2025-04-13

      16f18014 and 16f18026 - do not work. You will also need to add a payload field to 0x18. So the same modification as for the 13115 needs to be done for these circuits:
      16f131xx series:
      PIC16F13113, PIC16F13114, PIC16F13115, PIC16F13123, PIC16F13124, PIC16F13125, PIC16F13143, PIC16F13144, PIC16F13145
      16f180xx series:
      PIC16F18013, PIC16F18014, PIC16F18015, PIC16F18023, PIC16F18024, PIC16F18025, PIC16F18026, PIC16F18044, PIC16F18045, PIC16F18046, PIC16F18054, PIC16F18055,
      PIC16F18056, PIC16F18074, PIC16F18075, PIC16F18076
      16f181xx series:
      PIC16F18114, PIC16F18115, PIC16F18124, PIC16F18125, PIC16F18126, PIC16F18144,
      PIC16F18145, PIC16F18146, PIC16F18154, PIC16F18155, PIC16F18156, PIC16F18174,
      PIC16F18175, PIC16F18176

      16F15214 still doesn't work. In this case, it won't be the same problem as above, because this chip has bulk_erase without payload field. There will be some other error.

       

      Last edit: Dan Skareda 2025-04-13
      • Dan Skareda

        Dan Skareda - 2025-04-13

        I checked the relevant programming specification briefly (for 16f15214):
        1) LOAD (code 0x80) is 8 bits of code + 24 bits of address.
        2) BULK_ERASE (0x18) according to the bulk erase table cannot have the address F000 in the PC (the address space for bulk erase ends with EFFF).

        59 ICSP8_LOAD 80 00 00 -> OK
        57 ICSP8_SHORT 18 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        59 ICSP8_LOAD 80 F0 00 -> OK
        57 ICSP8_SHORT 18 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        0A WAIT_T3 -> OK
        04 FLUSH

        When I programmed and checked the chip, I found that at the beginning of the address space from 0000 (the entry point of the program after reset) there are all zeros (as if this space was not erased), but from address 700 and higher the program is stored correctly and even so somehow works (the LED on RA2 is on and at the same time it goes out cyclically, which indicates that the vector at address 0000 is not programmed). So the error will be in erase PFM/NVM (instruction code 0x18) - as if the sequence of bytes creating the control code or data was scattered and therefore the memory area from address 0000 could not be erased. Because the following programming (with instruction code 0x02) will take place at higher addresses fine.

         
  • Alberto Maccioni

    Here a new version with modifications for 16F18XXX .
    Regarding 16F152XX I'm not convinced about your hypothesis; a first bulk erase is issued with the correct adress.
    Anyways, now there is no extra erase without EEPROM .

     
    • Dan Skareda

      Dan Skareda - 2025-04-14

      No, it's the same.

      Code memory:
      0000: 3180 2802 3187 2FFD FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 
      07E0: FFFF FFFF FFFF FFFF FFFF FFFF 017E 01B8 0140 1112 1118 3004 0140 0698 3015 00F1 
      07F0: 304B 00F0 30BE 0B89 2FF3 0BF0 2FF3 0BF1 2FF3 3200 2FEB 3180 2802 0140 3187 2FE6 
      8000: FFFF FFFF FFFF FFFF FFFF FFFF FFFF 3FEF 3FFF FFFF 1FFF 3FFF 
      
      Regulator up and running after 78ms VPP=8,0V
      
      Regulator up and running after 0ms VPP=8,4V
      
      DevID: 0x30E6
      DevREV: 0x2008
      16F15214
      Device Information Area @0x8100
      8100: 0042 0031 0083 0001 0052 0041 0030 0013 0010 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 
      8110: 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 0401 0804 1003 0000 0000 0000 3FFF 3FFF 
      Device Configuration Information @0x8200
      8200: 0020 0020 0080 0000 0008 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
      8210: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
      Erase row size: 32 words
      Write latches: 32
      User rows: 128
      ->4096 Flash words
      EE data memory size: 0
      Pin count: 8
      Erasing ... completed
      Writing code ... completed
      Verifying code ... Error writing address   0: written 3180, read 0000
      Error writing address   1: written 2802, read 0000
      Error writing address   2: written 3187, read 0000
      Error writing address   3: written 2FFD, read 0000
      Error writing address   4: written 3FFF, read 0000
      Error writing address   5: written 3FFF, read 0000
      Error writing address   6: written 3FFF, read 0000
      Error writing address   7: written 3FFF, read 0000
      Error writing address   8: written 3FFF, read 0000
      Error writing address   9: written 3FFF, read 0000
      Error writing address   A: written 3FFF, read 0000
      Error writing address   B: written 3FFF, read 0000
      Error writing address   C: written 3FFF, read 0000
      Error writing address   D: written 3FFF, read 0000
      Error writing address   E: written 3FFF, read 0000
      Error writing address   F: written 3FFF, read 0000
      Error writing address  10: written 3FFF, read 0000
      Error writing address  11: written 3FFF, read 0000
      Error writing address  12: written 3FFF, read 0000
      Error writing address  13: written 3FFF, read 0000
      Error writing address  14: written 3FFF, read 0000
      completed, 21 errors
      Writing CONFIG area ... 
      completed, 0 errors
      
      End (0,28 s) 21 errors
      
       
  • Alberto Maccioni

    Can you try just to erase it? Simply write after opgui starts without loading any hex file.
    Then read the device; is it still partially written?

     
    • Dan Skareda

      Dan Skareda - 2025-04-15

      I tried to erase the 16f15214 chip according to your instructions and then read it. I don't know the addresses from the log, so I can't judge the success of the erase. Some data is read only at the end. I'm attaching the log. Why is the hex file saved after the reset so small? Is it because you don't put empty memory cells (0x3FFF) in it?

       

      Last edit: Dan Skareda 2025-04-15
      • Alberto Maccioni

        Looks correct, all locations contain 0x3FFF.
        Hex files contain locations not empty.
        Can you post the write log?

         
        • Dan Skareda

          Dan Skareda - 2025-04-16

          Here is a write to a completely empty (previously erased) chip. I verified the erase by reading before writing.

           
          • Dan Skareda

            Dan Skareda - 2025-04-16

            When I erase the code from address zero in the HEX file, the next address block in the sequence is programmed incorrectly - see attachment. So the first flashing of the data block after the erase function does not work correctly (or erase requires a longer time after the command), regardless of the address. Try to extremely increase the wait after erase 0x18 and preferably after 0xE0. Maybe it will help.

             
            • Alberto Maccioni

              Indeed it could be a matter of delay after bulk erase command.
              According to the programming manual 8.4ms should be enough; present delay is 14ms.
              Try this version with additional 14ms.

               
              • Dan Skareda

                Dan Skareda - 2025-04-17

                Nothing, timing didn't help. I'm trying different variations of the hex file to get an idea of where the error is, but it programs differently.

                For example this hex (line 0x80 is meaningless, it is only for programming purposes):

                0000: 3180 2802 3187 2FFD FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 
                0080: 3180 2802 3187 2FFD FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 
                07E0: FFFF FFFF FFFF FFFF FFFF FFFF 017E 01B8 0140 1112 1118 3004 0140 0698 3015 00F1 
                07F0: 304B 00F0 30BE 0B89 2FF3 0BF0 2FF3 0BF1 2FF3 3200 2FEB 3180 2802 0140 3187 2FE6 
                8000: FFFF FFFF FFFF FFFF FFFF FFFF FFFF 3FEF 3FFF FFFF 1FFF 3FFF
                

                It programs like this:

                0000: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
                0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
                0080: 3180 2802 3187 2FFD 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 
                07E0: 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 017E 01B8 0140 1112 1118 3004 0140 0698 3015 00F1 
                07F0: 304B 00F0 30BE 0B89 2FF3 0BF0 2FF3 0BF1 2FF3 3200 2FEB 3180 2802 0140 3187 2FE6 
                

                (config probably programs well, because verify is ok)

                Can't you think of something why the first line of data (here from address 0000 it is programmed twice and wrong?). I feel as if the program either cannot read the hex file, or the writing somehow overflows into programming zeros.

                Another code variation:

                07E0: FFFF FFFF FFFF FFFF FFFF FFFF 017E 01B8 0140 1112 1118 3004 0140 0698 3015 00F1 
                07F0: 304B 00F0 30BE 0B89 2FF3 0BF0 2FF3 0BF1 2FF3 3200 2FEB 3180 2802 0140 3187 2FE6 
                8000: FFFF FFFF FFFF FFFF FFFF FFFF FFFF 3FEF 3FFF FFFF 1FFF 3FFF
                

                This will program it like this:

                07E0: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
                07F0: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
                

                (config probably programs well because verify is ok)

                I'm attaching a hex file, can you try programming it into one of your chips, see if it's the same for you?

                 

                Last edit: Dan Skareda 2025-04-17
                • Alberto Maccioni

                  You can notice in the write log that data words are loaded with correct values, it's not a matter of errors reading a hex file.
                  32 words are written at the same time, and the first write after bulk erase is producing all 0.
                  Try with this version, just to exclude the delay theory; it has additional 250ms after bulk erase.

                   
                  • Dan Skareda

                    Dan Skareda - 2025-04-18

                    Unfortunately it's the same. Hex file:

                    0000: 3180 2802 3187 2FFD FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFF 
                    07E0: FFFF FFFF FFFF FFFF FFFF FFFF 017E 01B8 0140 1112 1118 3004 0140 0698 3015 00F1 
                    07F0: 304B 00F0 30BE 0B89 2FF3 0BF0 2FF3 0BF1 2FF3 3200 2FEB 3180 2802 0140 3187 2FE6 
                    8000: FFFF FFFF FFFF FFFF FFFF FFFF FFFF 3FEF 3FFF FFFF 1FFF 3FFF 
                    

                    was programmed like this:

                    0000: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
                    0010: 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 
                    07E0: 3FFF 3FFF 3FFF 3FFF 3FFF 3FFF 017E 01B8 0140 1112 1118 3004 0140 0698 3015 00F1 
                    07F0: 304B 00F0 30BE 0B89 2FF3 0BF0 2FF3 0BF1 2FF3 3200 2FEB 3180 2802 0140 3187 2FE6 
                    
                     

                    Last edit: Dan Skareda 2025-04-18
                    • Dan Skareda

                      Dan Skareda - 2025-04-18

                      ChatGPT studied the programmer files and found possible solutions, but the problem is that I have old programmer source codes, because you have probably already fixed this when troubleshooting 16f13115 programming. If you could not find the problem, please publish the source codes for the current version (which fixes 13115 programming) so that I can also help with finding the error.

                      Please verify this finding in 16f18xxx:

                      In this section of your code:

                      for (valid = 0; i < dim && !valid; i += valid ? 0 : rowN) {
                          valid = 0;
                          for (k = 0; k < rowN; k++) {
                              if (memCODE_W[i + k] < 0x3FFF)
                                  valid = 1;
                          }
                      }
                      

                      You're trying to skip 32-word blocks (rowN) that are completely empty (0x3FFF = erased flash). But here's what goes wrong:

                      You increment i += rowN inside the loop condition before checking valid.
                      So even if a block contains valid data, i might be incremented too early.
                      This causes the main write loop to reference a memory block that contains no valid data  i.e., zeros or uninitialized.
                      

                      Thus, when you later write this block:

                      for (k = 0; k < rowN && i < dim; k++) {
                          bufferU[j++] = ICSP8_LOAD;
                          bufferU[j++] = (k < rowN - 1) ? LOAD_NVM_INC : LOAD_NVM;
                          bufferU[j++] = memCODE_W[i + k] >> 8;
                          bufferU[j++] = memCODE_W[i + k] & 0xFF;
                      }
                      

                      It ends up writing all zeros because i is already pointing to the next (invalid) block, and memCODE_W[i + k] contains uninitialized data.)

                       

                      Last edit: Dan Skareda 2025-04-19
                      • Dan Skareda

                        Dan Skareda - 2025-04-19

                        I'm trying each version opgui.exe again and here is the result:
                        - version for 13115 - works 13115
                        - version for 18xxx - doesn't work 18014 or 18026 (doesn't works 13115)
                        - version for 15214 - doesn't work 15214 (doesn't works 13115)

                         

                        Last edit: Dan Skareda 2025-04-19
                      • Alberto Maccioni

                        ChatGPT? Hahaha, what a colossal waste of energy and silicon!
                        I'll answer this one, just to prove it doesn't get it.
                        The increment is not simply inside the loop, it's at the end of it, and it checks "valid" right after it is assigned the correct value.
                        Uninitialized memory, if it existed, would not be 0 but 0x3FFF.
                        In no way the following code can load zeros.
                        You see? Current AI are completely stupid, they don't know things, simply assume something is wrong because it is similar to one of the most common mistakes.
                        Sure, it sounds credible, and perfectly written; still, 100% BS.
                        Do yourself a favour: never believe an AI explanation for a bug.
                        By the way, you can see in the log file that data is loaded correctly (i.e. the correct command and payload is sent).
                        Also, this type of bug would show in all devices and would have been caught a long time ago.
                        The real problem could have two possible causes:
                        1) I did not read carefully or correctly interpret the programming specs (like with 13115)
                        2) Microchip did not write all details or missed something. This is unlikely but it happened a few times before.
                        In either case, ChatGPT would not be able to say anything useful; even if it managed to read the programming specs, it is too stupid to figure out anything.
                        Here the source code.

                         
                        • Dan Skareda

                          Dan Skareda - 2025-04-19

                          Thanks for the source code, the GCC compiler works for me, so I can compile the next versions myself. I'll try to figure something out.

                           
<< < 1 2 3 4 > >> (Page 2 of 4)

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.