Hot!PIC16F1459 Full Speed USB Application Programing Problem

Author
kjo
Starting Member
  • Total Posts : 70
  • Reward points : 0
  • Joined: 2006/07/11 15:11:02
  • Location: 0
  • Status: offline
2019/03/22 18:37:44 (permalink)
0

PIC16F1459 Full Speed USB Application Programing Problem

Background... fully working USB application written in C compiled with XC8 1.45 using MPLABX 5.15 and ICD3 on PIC18F14K50. Programming via ICSP High voltage mode on VPP using pins 18, 19 PGD, PGC, external 12MHz XOSC.

I want to convert code to PIC16F1459 to take advantage of internal clock modes. I can get the 1459 to program and run using the legacy pins 18, 19 PGD, PGC by setting configuration to LVP=ON and selecting LVP in the ICD3 setup. The program connects and runs. I have several MLA programs that work this way.

However, if I move PGC, PGD to the normal high voltage mode ICSP pins 15, 16 the ICD3 always fails to read the device ID (0x0) reported. I’m stumped why I can’t high voltage vpp program this device.

Kevin
#1

18 Replies Related Threads

    NorthGuy
    Super Member
    • Total Posts : 5308
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/23 07:13:17 (permalink)
    0
    You certainly can. I program lots of PIC16F1454 this way. There must be something incorrect in your connection.
    #2
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/23 17:24:51 (permalink)
    0
    I have just 5 wires from a rj45 jack  & 6" pigtail to IVD3 to a solderless breadboard with the 1459.
    Vpp > p4
    Vdd > p1
    Vss > p20
    PGC > p15
    PGD > p16
     
    This works with many other PICs, but not this one. I tried both VDD first & the more common VPP first at 4 & 5 volts.
    Still cant read device ID. I get same thing with IC4.
    #3
    qhb
    Superb Member
    • Total Posts : 9621
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/23 23:12:24 (permalink)
    0
    Apart from Vss, what else is connected to any of those signals?
     
    #4
    mpgmike
    Senior Member
    • Total Posts : 109
    • Reward points : 0
    • Joined: 2014/01/23 17:27:06
    • Location: NJ
    • Status: online
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 01:44:32 (permalink)
    0
    If you are trying to just port K50 code to the 16F, did you change the number of buffers & their sizes?  The 16F has half the USB buffers, each 1/2 the size of the 18F14K50.  You may be trying to write 2 things to the same memory regions.  Also, the USB buffers start at 0x200 on the K50, and 0x2000 for the 16F1459.
    post edited by mpgmike - 2019/03/24 01:51:18
    #5
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 07:08:15 (permalink)
    0
    qhb
    Apart from Vss, what else is connected to any of those signals? 

    For the solderless BB fixture nothing but the programmer
    #6
    NorthGuy
    Super Member
    • Total Posts : 5308
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 07:28:54 (permalink)
    0
    Take a scope and see what you get on MCLR, PGC and PGD during the programming attempts. Probe directly at the PIC's pins (not in breadboard or anywhere else). Also, measure the voltage at VDD to see if it's normal.
     
    #7
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 08:13:18 (permalink)
    0
    mpgmike
    If you are trying to just port K50 code to the 16F, did you change the number of buffers & their sizes?  The 16F has half the USB buffers, each 1/2 the size of the 18F14K50.  You may be trying to write 2 things to the same memory regions.  Also, the USB buffers start at 0x200 on the K50, and 0x2000 for the 16F1459.

    But I can’t even get into programming mode.......
    Regarding the differences, the code is derived from the MC MLA, and I used the appropriate code sections for the 1459 in the conversion. The compiler and linker are happy.

    I am a bit confused on the correct entry into LVP mode. A virgin erased device has LVP=1, so programming the 1459 via ra0/ra1 with the ICD3 set to LVP should work fine and did on one chip. The test application ran fine. To HVP one has to use rc0/rc1 which should program the chip regardless of the current state of the LVP bit. I recompiled the code with LVP=0 and tried to program but I would always get bad device ID 0x0.
    So in at least one case I said program any way. Doing this, at least one of the chips I tried must have programmed as the test application (MLA USB HID DEMO) is running. And if I try to LVP the programmer says the LVP bit is 0 and to use HVP, so the chip must have HVProgrammed anyhow.

    Remaining confused with this device....
    #8
    NorthGuy
    Super Member
    • Total Posts : 5308
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 09:53:14 (permalink)
    0
    kjoconnor
    I am a bit confused on the correct entry into LVP mode. A virgin erased device has LVP=1, so programming the 1459 via ra0/ra1 with the ICD3 set to LVP should work fine and did on one chip. The test application ran fine. To HVP one has to use rc0/rc1 which should program the chip regardless of the current state of the LVP bit. I recompiled the code with LVP=0 and tried to program but I would always get bad device ID 0x0.
    So in at least one case I said program any way. Doing this, at least one of the chips I tried must have programmed as the test application (MLA USB HID DEMO) is running. And if I try to LVP the programmer says the LVP bit is 0 and to use HVP, so the chip must have HVProgrammed anyhow.



    Indeed. There are 4 different things:
     
    1. There are two programming modes - LVP and HVP, which differ by the voltage applied to MCLR. You set them with your programmer settings and can measure the voltage on MCLR to see what you're doing.
     
    2. There are two pairs of pins - RA0/RA1 only supports LVP (and also may die if you exceed 3.3V).
    RC0/RC1 supports both HVP and LVP.
     
    3. There is an LVP config bit programmed on your PIC (comes with ON from factory). If it is OFF, all attempts to use LVP are futile. Only HVP will work.
     
    4. There's an LVP bit in your HEX file. When you program the HEX file, you attempt to move it to your device. If it is OFF, you must use HVP for programming, otherwise the LVP bit on your PIC won't change (safety feature to make sure the LVP programmer cannot lock itself out).
     
    To accomplish what you want, you need to sort these 4 things as following:
     
    1. Make sure your programmer is set to use HVP
    2. Make sure you use RC0/RC1
    3. Doesn't matter
    4. Doesn't matter
     
    Do not change these settings. If this doesn't work, keep working on your connection. This is where 99% of the problems are.
     
    #9
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 11:46:40 (permalink)
    0
    Update:
    Using the EXACT hardware connections to rc0/rc1 solderless breadboard with only 5 wires. I closed MPLABX IDE and opened IPE. Connected the ICD3 and erased the device. IDed device with rev 0x1006 just fine. I then reprogrammed with hex file just fine. My ICD4 behaves the same.

    This has to be some kind of problem in communication between MPLABX IDE and ICD not anything in my connections.

    Something else I noted in doing LVP on ra0/ra1. When I set power on on ICD3 in MPLABX configurations and change the voltage for Vdd, the change is NOT sent to the ICD3. I have to kill MPLABX and restart for the change to appear. I have tried clearing the cache dir. This must be another MPLABX 5.10 bug.
    #10
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 12:20:21 (permalink)
    0
    Another update:
    After erasing a device with IPE... and attempting to program 3 times from IDE with external 5V power I get this:
     
     
    Note the first attempt IDs and fails programming, second IDs & programs, third (after being programmed) fails to ID. I don't get it....
     
    *****************************************************

    Connecting to MPLAB ICD 3...

    Currently loaded firmware on ICD 3
    Firmware Suite Version.....01.54.00
    Firmware type..............Enhanced Midrange

    Target voltage detected
    Target device PIC16F1459 found.
    Device Revision ID = 1006

    Device Erased...

    Programming...

    The following memory area(s) will be programmed:
    program memory: start address = 0x0, end address = 0x10df
    configuration memory
    program memory
    Address: 0 Expected Value: 3180 Received Value: 0
    Failed to program device

    *****************************************************

    Connecting to MPLAB ICD 3...

    Currently loaded firmware on ICD 3
    Firmware Suite Version.....01.54.00
    Firmware type..............Enhanced Midrange

    Target voltage detected
    Target device PIC16F1459 found.
    Device Revision ID = 1006

    Device Erased...

    Programming...

    The following memory area(s) will be programmed:
    program memory: start address = 0x0, end address = 0x10df
    configuration memory
    Programming/Verify complete

    *****************************************************

    Connecting to MPLAB ICD 3...

    Currently loaded firmware on ICD 3
    Firmware Suite Version.....01.54.00
    Firmware type..............Enhanced Midrange

    Target voltage detected
    Target Device ID (0x0) is an Invalid Device ID. Please check your connections to the Target Device.

    #11
    NorthGuy
    Super Member
    • Total Posts : 5308
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 13:19:33 (permalink)
    +1 (1)
    kjoconnor
    Using the EXACT hardware connections to rc0/rc1 solderless breadboard with only 5 wires. I closed MPLABX IDE and opened IPE. Connected the ICD3 and erased the device. IDed device with rev 0x1006 just fine. I then reprogrammed with hex file just fine. My ICD4 behaves the same.



    I guess your IDE uses LVP mode, while IPE uses HVP.
    #12
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 15:43:43 (permalink)
    0
    NorthGuy
    I guess your IDE uses LVP mode, while IPE uses HVP.

    Im not sure what you mean...
    LVP/HVP is just a check box in the ICD configuration for both IDE & IPE, and my previous example showed rather inconsistent behavior with sequential programming attempts.
    #13
    NorthGuy
    Super Member
    • Total Posts : 5308
    • Reward points : 0
    • Joined: 2014/02/23 14:23:23
    • Location: Northern Canada
    • Status: online
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 17:39:17 (permalink)
    0
    kjoconnor
    NorthGuy
    I guess your IDE uses LVP mode, while IPE uses HVP.

    Im not sure what you mean...
    LVP/HVP is just a check box in the ICD configuration for both IDE & IPE, and my previous example showed rather inconsistent behavior with sequential programming attempts.



    That's what I mean. You have LVP checked in IDE, while you have HVP checked in IPE.
     
    Of course, it's only a guess. It's impossible to see your settings from here and you keep them in secret, so I can't tell what they are. However, I can tell what's important - settings, voltages, connections ... Instead, you keep changing things which are of no consequence. I even can tell you how it all ends. After some (possibly long) time, it suddenly starts working, and you may not even know why :)
     
    #14
    qhb
    Superb Member
    • Total Posts : 9621
    • Reward points : 0
    • Joined: 2016/06/05 14:55:32
    • Location: One step ahead...
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/24 17:54:10 (permalink)
    0
    Some recent posts on this board imply that ICD settings don't take effect instantly.
    You may need to exit and restart MPLABX to be sure a new setting has taken effect.
     
    #15
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/25 07:17:52 (permalink)
    0
    qhb
    Some recent posts on this board imply that ICD settings don't take effect instantly.
    You may need to exit and restart MPLABX to be sure a new setting has taken effect.



    I have noticed that with with the IDE. Makes things a bit more confusing.
    #16
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/25 12:22:48 (permalink)
    0
    Another update:
    Using MPLABX, I plugged in the AC164113 test fixture and ran the ICD3 diag and got nothing in response to the test, as if the fixture was not there. Went back to MPLAB 8.92 and forced reloading of 01.28.90 firmware. ICD3 passes all tests and HVP the 16F1459 in 8.92. 
    Switched back to MPLABX which loaded 01.54.00 firmware. Passes tests and programs 16F1459 with HVP now.
    I'm not sure this is explainable.... but I appreciate all the suggestions. 
    #17
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/25 12:26:09 (permalink)
    0
    I also think it is a serious bug that, when powering from the ICD, voltage changes are not communicated to the ICD unless you exit MPLABX or completely deselect the ICD and re-select it. Its a good way to put 5V on 3.3v USB LVP pins. Am I correct? Has this been elevated to MC?
    #18
    kjo
    Starting Member
    • Total Posts : 70
    • Reward points : 0
    • Joined: 2006/07/11 15:11:02
    • Location: 0
    • Status: offline
    Re: PIC16F1459 Full Speed USB Application Programing Problem 2019/03/25 15:49:28 (permalink)
    +1 (1)
    mpgmike
    If you are trying to just port K50 code to the 16F, did you change the number of buffers & their sizes?  The 16F has half the USB buffers, each 1/2 the size of the 18F14K50.  You may be trying to write 2 things to the same memory regions.  Also, the USB buffers start at 0x200 on the K50, and 0x2000 for the 16F1459.



    Hi Mike,
    My USB CDC Data Logger is now running on both the F14K50 and 16F1459! A lot of people have bashed the Microchip MLA over the years, but I am very happy with the operation of the current USB stack. Your buffer caution is well noted. I directly ported the exact code used in the 18F14K50 to the 16F1459 with appropriate #defines for the difference in configuration words. The USB stack would enumerate and hang. (The difference in buffers) One header file with 4 lines to differentiate buffers and it is running!
     
    I only wish Microchip made this 16F1459 20 pin device with a bit more memory. While there is room for a bootloader on the 18F part, a USB bootloader and application just wont fit on the 16F part. Bummer.
    #19
    Jump to:
    © 2019 APG vNext Commercial Version 4.5