Going backwards, can't even get a basic blinky working now


+ Reply to Thread
Results 1 to 27 of 27
  1. #1
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598

    Question Going backwards, can't even get a basic blinky working now

    Started trying to get USART going on the LAB X1, but was getting garbage - couldn't figure it out, so I moved to a breadboard and started at the beginning. It doesn't get much more basic than this on a 16F877; blinky on pin D1.

    Code:
    #CONFIG
        __config _HS_OSC & _WDT_OFF & _WRT_OFF & _BODEN_ON & _LVP_OFF  & _CPD_OFF & _PWRTE_OFF & _DEBUG_OFF
    #ENDCONFIG
    
    DEFINE  OSC     20
    
    ADCON1 = 7              ' A/D off, all digital
    TRISD = %00000000
    PORTD = %00000000
    
    START:  PORTD = %00000000
            PAUSE   500      
            PORTD = %00000010
            PAUSE   500      
    
            GOTO    START
    Finish: end
    Compiled using PK4 successfully:

    Code:
    DFP Version Used : PIC16Fxxx_DFP,1.4.149,Microchip
    *****************************************************
    
    Connecting to MPLAB PICkit 4
    Currently loaded versions:
    Application version...........00.09.46
    Boot version..................01.00.00
    Script version................00.05.58
    Script build number...........abbfe90327
    Tool pack version ............1.15.1688
    Target voltage detected
    Target device PIC16F877 found.
    Device Revision Id  = 0x6
    Device Id = 0x9a0
    *****************************************************
    Erasing...
    Erase successful
    *****************************************************
    Erasing...
    The following memory area(s) will be programmed:
    program memory: start address = 0x0, end address = 0x1fff
    EEData memory
    Programming/Verify complete
     Program Report
    01-May-2023, 17:01:53
    Device Type:PIC16F877
    Program Succeeded.
    PK4 Verify Report
    01-May-2023, 17:01:53
    Device Type:PIC16F877
    *****************************************************
    The following memory area(s) will be verified:
    program memory: start address = 0x0, end address = 0x1fff
    EEData memory
    Verification successful.
    Verify Succeeded.
    • I added two power LEDs at the top to show both rails are powered.

      Blinky LED is on pin D1, and yet nothing happens.

      LED comes on if I manually apply 5V to pin.

      I've changed 20MHz OSC and caps.

      Changed MCU.

    I've been trying to figure this out for waaaay too long now, I feel I'm getting dumber by the minute.

    Robert

    Name:  Blinky 16F877.jpg
Views: 2584
Size:  181.2 KB


    EDIT: For a sec I thought my CONFIG was obsolete, but that looks ok.
    Last edited by Demon; - 1st May 2023 at 22:27.
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  2. #2
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    It gets dumber still.

    I use this code in parallel with a 18F4550.

    Code:
    INCLUDE "ALLDIGITAL.pbp"        ; Set all pins as digital
    
    TRISD = %00000000
    PORTD = %00000000
    
    PAUSE   2000      
    
    START:  PORTD = %10101010
            PAUSE   500      
            PORTD = %01010101
            PAUSE   500      
    
            GOTO    START
    Finish: end
    It compiles and works just fine on the Lab X1.

    It compiles on the breadboard, but doesn't run.

    I move it to the Lab X1, the darn thing runs fine...?

    ---------------------------------------------------

    3 ICs of 16F877 compile, but don't do nothing (including a new one from my stock).

    1 of the old ones compiles and runs on the Lab X1, it does nothing on the breadboard.

    Robert



    EDIT: Oh yeah, I'm using my "weirdo" cable for my X1, and my new cable for the breadboard.
    Last edited by Demon; - 1st May 2023 at 23:35.

  3. #3
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Update: compiled that 16F877 on the Lab X1, it blinks, but it's not consistent.

    Works a bit, then stops.

    If I lightly touch the IC on the X1, it starts up for some random time period.

    Now I noticed I can wave my hand over the X1 to affect it.

    Robert


    EDIT: Linoleum floor, no carpet, barefeet.

  4. #4
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Connected my Saleae probe to the oscillator on the 16F877 while it's on the X1, the thing spits out like crazy on both pins.

    Name:  16F877 osc at 20MHz on Saleae.png
Views: 2372
Size:  102.0 KB

    But when I connect to the osc while it's on the breadboard, nothing, no activity. Something is definitely wonky on that breadboard.

    I tried with 18, 22 and now 33pF caps just to eliminate that possibility.

    Might have dead circuits inside, that sucker's brand new too.

  5. #5
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    This pic was just out of curiosity. I never saw what was going on during ICSP.

    Gotta love this probe.

    Name:  16F877 ICSP on Saleae.png
Views: 1842
Size:  87.5 KB

  6. #6
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    I wonder if I haven't damaged by PICs with static somehow:
    - 2 of my workhorse aren't programming on breadboard, ZIF adapter or Lab X1.
    - 1 new one has the same problems.
    - 1 workhorse works, but intermittently.
    - and then there's the 18F4550 that just works, on anything.

    I've handled all these ICs the same, same surfaces, same work area, nobody else here messing with them.

    I must be doing something really dumb on the Lab X1, my configs or osc setting. Thing is, I haven't changed anything, the X1 OSC jumpers are always set at 20 MHz for all my ICs (A12, B12 and C23, J3 is at top position when looking at the X1 properly).

    I set the 18F4550 for 1 second blink intervals, and it seems to be keeping time. I also set the 16F877 at 1 second blink intervals, but it seems to be going twice at fast.

    Also, the 16F877 take a long time to erase and program; the 18F4550 takes a fraction of that, maybe 25% at max. And it's technically the same code, just the config changes.

    Robert

  7. #7
    Join Date
    May 2013
    Location
    australia
    Posts
    2,389


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    the legs of most crystals are too thin to make good connections on most breadboards,
    aside from the capacitive loading effects from the parallel connector strips , success is difficult under such adverse conditions
    Warning I'm not a teacher

  8. #8
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Also, if you're using a crystal then probing the OSC1 and OSC2 pins is going to throw things off, and could even make it stop oscillating.
    Usually with a 20M xtal you want smaller caps, not larger ones. You might get away with probing the OSC2 pin since that's the output drive...

    IMHO you're better off using the LABX1 instead of a breadboard. That ICS502 clock generator will give you a nice logic-level output.
    For the 18F4550 I'd set the CONFIG to use external clock mode, not xtal (EC, ECIO or ECPLL)

    Also, the 16F877 take a long time to erase and program
    The PK4 can take a while to switch chips, and it's not great with some of those really old devices. It's even been known to blow them up from time to time (the VPP generator can overshoot > 20V)
    Last edited by tumbleweed; - 2nd May 2023 at 14:11.

  9. #9
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Quote Originally Posted by tumbleweed View Post
    Also, if you're using a crystal then probing the OSC1 and OSC2 pins is going to throw things off, and could even make it stop oscillating.
    Usually with a 20M xtal you want smaller caps, not larger ones. You might get away with probing the OSC2 pin since that's the output drive...
    Yeah, I noticed that rather quickly on the Lab X1. But even probing only OSC2 on both setups, it quickly became apparent something was terribly wrong with the breadboard.

    I did get OSC1 to function while being probed on the X1. That's wht I wasn't really concerned when the intervals on both pins became "slightly irregular", but hey, the PIC still worked.

    I'm tempted to solder the cap right off the side of the 16F877.


    IMHO you're better off using the LABX1 instead of a breadboard. That ICS502 clock generator will give you a nice logic-level output.
    For the 18F4550 I'd set the CONFIG to use external clock mode, not xtal (EC, ECIO or ECPLL)
    Yeah, but this was just to see if the IC had a heartbeat.


    The PK4 can take a while to switch chips, and it's not great with some of those really old devices.
    Thing is, the PK4 took forever even if I was programming them sequentially in batch mode; keeping the 18F4550 separate.


    It's even been known to blow them up from time to time (the VPP generator can overshoot > 20V)
    You see, now that is very worrisome. Gonna go google voltage limiting. I remember seeing voltage clamps last time I was "electronically active".

    I just don't know to what limit I should set the clamp for. I suppose the datasheet will give me some indication in "maximum specs".

    Robert

  10. #10
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Eeeep, 20V That's a tad beyond max rating for a 16F877.

    Name:  16F877 max elect char.png
Views: 1779
Size:  98.4 KB


    Reading up on Zener Transient Suppression:

    https://www.electronics-tutorials.ws...ppression.html


    And then off to Digikey for a supply of Zs.

    Robert


    EDIT: These look nice:

    https://www.digikey.ca/en/products/detail/onsemi/1N5243BTR/977601
    Last edited by Demon; - 2nd May 2023 at 17:57.

  11. #11
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Looked up the 18F4550, and it's not better.

    Voltage on MCLR with respect to VSS (Note 2) .......................... 0V to +13.25V

    Note 2: ... a series resistor of 50-100Ω should be used when applying a “low” level to the MCLR/VPP/RE3 pin, rather than pulling this pin directly to VSS.

    Maybe I've just been lucky, or my PK4 has a thing against 16F pics.

    Either way, a little prevention added to my circuits shouldn't hurt; like a zener on MCLR, and 50-100R when pulled low.

    Robert
    My Creality Ender 3 S1 Plus is a giant paperweight that can't even be used as a boat anchor, cause I'd be fined for polluting our waterways with electronic devices.

    Not as dumb as yesterday, but stupider than tomorrow!

  12. #12
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    It's not letting me EDIT that post so I can fix the hyperink to the diodes.

    Zener Diode 13 V 500 mW ±5%

  13. #13
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    I guess you have biased the MCLR pin, right?

    Ioannis

  14. #14


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Why don't you get rid of the crystal and use the pic internal oscillator ? That should stop your hand capacitance causing problems on the crystal circuit.

  15. #15
    Join Date
    Aug 2011
    Posts
    412


    2 out of 2 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Regarding the overshoot issue, if your PICkit 4 is serial number BUR20xxxxxxx or later (-R2) then it has a mod in it to reduce the overshoot so it's not as much of a problem. Before that, they used to recommend using a 470R in series with the PK4 MCLR connection to the target.

    From ETN37:
    Some PIC16/18 devices have options to use high voltage on VPP or NMCLR to program the device. On some
    devices, the VPP/NMCLR pin has special ESD protection. Overshoot on the pin can result in a reset condition or
    current consumption outside of the specification. To avoid this situation, the data sheets for these devices
    recommend the use of an RCR network with a pull-up, a power up charge capacitor and a series resistor
    configuration into VPP. A series resistor of 470 ohms is used to dampen any overshoot and to limit current into
    VPP/NMCLR

  16. #16
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Quote Originally Posted by Ioannis View Post
    I guess you have biased the MCLR pin, right?

    Ioannis
    I don't know the term "bias" in relation to the MCLR pin; but if you mean put a zener upside down so it breaks down over a given voltage, then yes, I'm biasing the pin.

    Scroll down here to the paragraph called Zener Transient Suppression.

    https://www.electronics-tutorials.ws...ppression.html

    I'm going to go one step further with zener diodes. I'm gonna add a 1N5243BTR on MCLR to break down at 13 volts, and a ‎1N5232BTR on VDD to break down at 5.6 volts (specs say 5.5V is "max" - but I figure they're leaving a small margin for safety).

    Unless someone has a good reason why I shouldn't...?


    Why don't you get rid of the crystal and use the pic internal oscillator ? That should stop your hand capacitance causing problems on the crystal circuit.
    I'm not seeing an internal oscillator on the 16F877: LP, XT, HS and RC. If you mean RC, it uses a capacitor as well. Won't that cause the same issues? They also mention other issues, like accuracy/tolerance of the resistor and capacitor, as well as temperature.

    This will ultimately run a USB or USART connection as fast as I can.


    I've tested the new breadboard using two gold pins from a header as probes (those pins are thick, clean and square) and I'm still getting a lot of "looshish" spots in some areas. The much thinner pins on capacitors, oscillators and some resistors must definitely be messing up my circuit.


    Also, I think I have some capacitor/interference issue with my Lab X1 as well (probably not even related with my breadboard issues, just bad timing). Waving my hand over the X1 should not affect operations. It's possible it now has a defect; I bought it when they came out.


    I'm looking at using fiberglass breadboards and soldering my components. I've been thinking of making my own Arduino-ish circuits for testing for a very long time. This might be the time to give that a try.


    Side note: the tips on my Aoyue 738 soldering station are garbage. Bought some new ones on Amazon and they just don't last. One comment on the listing was "I've had packs of gum that lasted longer"; he wasn't exaggerating.

    I bought new soldering paste since mine was 20 years old and had spent winter in unheated garage. I've just received today one of those brass brush balls to clean the tip; hoping that works better than that water sponge (never liked that).

    Robert

  17. #17
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Quote Originally Posted by tumbleweed View Post
    Regarding the overshoot issue, if your PICkit 4 is serial number BUR20xxxxxxx or later (-R2) then it has a mod in it to reduce the overshoot so it's not as much of a problem. Before that, they used to recommend using a 470R in series with the PK4 MCLR connection to the target.

    From ETN37:
    BUR223673449


    Do you mean -R like a command line? Taken from the IPECMD docs:

    R<on><off>

    Safe/Restricted mode (Applicable only for MPLAB PM3)

    Default = None

    I'm running the PK4 from MCS+5.

    Robert

  18. #18
    Join Date
    Aug 2011
    Posts
    412


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    BUR223673449
    Then it has the mod to address the ETN37 overshoot issue.

    Do you mean -R like a command line?
    No, I meant the PK4 assy number... usually on the label right above "BURxxx". On one of mine it's "10-10094-R2"

    There's probably no real reason to put a zener on VDD. The overshoot was only on the VPP/MCLR high-voltage generator.

  19. #19
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Quote Originally Posted by tumbleweed View Post
    Then it has the mod to address the ETN37 overshoot issue.

    No, I meant the PK4 assy number... usually on the label right above "BURxxx". On one of mine it's "10-10094-R2". ...
    Mine is up to -R6.


    Quote Originally Posted by tumbleweed View Post
    ... There's probably no real reason to put a zener on VDD. The overshoot was only on the VPP/MCLR high-voltage generator.
    I wasn't really thinking of protecting VDD from the PK4. This was more to protect the circuit from being driven by who-knows-what wall-adapter by a user.

    Robert

  20. #20
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Talk about varying absolute maximum specs from one PIC to another:

    16F877
    Voltage on VDD with respect to VSS.................+7.5V
    Voltage on MCLR with respect to VSS...............+14V
    Was plan A, but I'm forgetting about the 16F877; keeping it for disposable pet projects now. I've wasted enough days trying to figure what I'm doing wrong.


    18F4550
    Voltage on VDD with respect to VSS.................+7.5V
    Voltage on MCLR with respect to VSS...............+13.25V
    Gotta be prepared to use this series, in case I ever get the C++ USB code figured out.


    18F26K22
    Voltage on VDD with respect to VSS.................+6.5V
    Voltage on MCLR with respect to VSS...............+11V
    This is my plan B unless there's something even sweeter out there, has 2 USART circuits. I could use one to talk to the PC via USB, and the other to talk with other PICs. Starting to test these as soon as my ZIFs come in. I'm making my own soldered test boards; not trusting the Lab-X1 with its funky blinking for no apparent reason.


    I wish I knew absolute specs varied this much before; I never paid much attention to that. I've already put in a few order to DigiKey, Newark and Mouser for all sorts of odds and ends;including some Zeners.

    Robert

    "I'm killing the planet single-handedly with shipping."

  21. #21
    Join Date
    Aug 2011
    Posts
    412


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    And then you've got the newer K and Q families...
    18F26K40
    Voltage on VDD with respect to VSS.................+6.5V
    Voltage on MCLR with respect to VSS...............+9V
    The 26K22 has been one of my "goto" devices for a long time.

  22. #22
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Yeah, I got a bunch of 18F26K22 and 18F46K22 from MicroChipDirect a while ago, as well as a bunch of other ICs (sensors, i/O interfaces, etc).

    Has MicroChip come up with a newer better USB series than the 18F2550/18F4550?


    EDIT: Yeah, this is an interesting MCU: PIC18F04/05/14/15Q40.

    I need to find a smaller package though, something with 3-4 I/O pins that can USART at a good clip. These look interesting (not really interested in the low-voltage line):

    16F18015/25/44/45
    16F18313/18323


    (...runs off to MicroChip Direct to see if they still offer 3-demos to customers...)

    Robert
    Last edited by Demon; - 4th May 2023 at 14:04.

  23. #23
    Join Date
    Aug 2011
    Posts
    412


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    PIC18F04/05/14/15Q40
    You won't be programming those with PBP.
    If you're sticking with PBP, make sure you pick something that's supported, since a lot of the newer chips aren't (and won't be).

    Has MicroChip come up with a newer better USB series than the 18F2550/18F4550?
    In the 18F family there's the 18F2xK50/18F4xK50, but that's about it. They're pretty similar to the 4550, just a bit newer.

  24. #24
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Quote Originally Posted by tumbleweed View Post
    In the 18F family there's the 18F2xK50/18F4xK50, but that's about it. They're pretty similar to the 4550, just a bit newer.

    And 50% cheaper on Digikey in Canada. :O

    I guess they're phasing out the older series...?

    Robert

  25. #25
    Join Date
    Aug 2011
    Posts
    412


    1 out of 1 members found this post helpful. Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Microchip rarely obsoletes a device. You can still get most ancient pics.
    What they do is to raise the price, so you're always better off using the newer devices... they'll be cheaper and likely more available.

  26. #26
    Join Date
    Nov 2003
    Location
    Greece
    Posts
    3,807


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Regarding the zeners, you do not have to worry about that. Programmer takes care of the voltages needed for every chip by its own.

    When I said about bias, I meant that you did not left the pin MCLR free in the air (especially if that pin is programmed as a MCLR pin). It should have a resistor of around 10K to the Vdd rail.

    Otherwise this could lead to random resets of the PIC.

    Ioannis

  27. #27
    Join Date
    Jan 2005
    Location
    Montreal, Quebec, Canada
    Posts
    2,598


    Did you find this post helpful? Yes | No

    Default Re: Going backwards, can't even get a basic blinky working now

    Quote Originally Posted by Ioannis View Post
    Regarding the zeners, you do not have to worry about that. Programmer takes care of the voltages needed for every chip by its own. ...

    Ioannis
    Maybe, but right now nothing is working as it should so I'm trying to eliminate as much of the possibilities as possible.


    Quote Originally Posted by Ioannis View Post
    ... When I said about bias, I meant that you did not left the pin MCLR free in the air (especially if that pin is programmed as a MCLR pin). It should have a resistor of around 10K to the Vdd rail.

    Otherwise this could lead to random resets of the PIC.

    Ioannis
    Oh definitely pulled up to VDD with 10K, and added 100R when reset to VSS. You call it bias, I call it floating.

    Robert

Similar Threads

  1. DT_INTS-14 (Blinky Light) Help ?
    By andybarrett1 in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 4th November 2015, 21:28
  2. Replies: 3
    Last Post: - 15th April 2015, 04:58
  3. 12F683 - basic code not working
    By Scampy in forum mel PIC BASIC Pro
    Replies: 56
    Last Post: - 12th February 2014, 00:29
  4. Blinky not working with TOGGLE
    By AndrewC in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 22nd November 2008, 08:45
  5. My first Blinky!
    By nomad in forum mel PIC BASIC Pro
    Replies: 17
    Last Post: - 25th September 2007, 17:29

Members who have read this thread : 17

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts