PDA

View Full Version : Going backwards, can't even get a basic blinky working now



Demon
- 1st May 2023, 22:07
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.


#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:


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

9376


EDIT: For a sec I thought my CONFIG was obsolete, but that looks ok.

Demon
- 1st May 2023, 23:31
It gets dumber still. :D

I use this code in parallel with a 18F4550.


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. :D

Demon
- 1st May 2023, 23:39
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.

Demon
- 2nd May 2023, 02:46
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.

9377

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.

Demon
- 2nd May 2023, 03:08
This pic was just out of curiosity. I never saw what was going on during ICSP.

Gotta love this probe.

9378

Demon
- 2nd May 2023, 04:04
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

richard
- 2nd May 2023, 08:34
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

tumbleweed
- 2nd May 2023, 14:05
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)

Demon
- 2nd May 2023, 17:01
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. :D 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

Demon
- 2nd May 2023, 17:16
Eeeep, 20V That's a tad beyond max rating for a 16F877. :D

9379


Reading up on Zener Transient Suppression:

https://www.electronics-tutorials.ws/power/transient-suppression.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 (Zener Diode 13 V 500 mW ±5%)

Demon
- 2nd May 2023, 17:22
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. :D

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

Robert

Demon
- 2nd May 2023, 18:02
It's not letting me EDIT that post so I can fix the hyperink to the diodes.

Zener Diode 13 V 500 mW ±5% (https://www.digikey.ca/en/products/detail/onsemi/1N5243BTR/977601)

Ioannis
- 2nd May 2023, 19:36
I guess you have biased the MCLR pin, right?

Ioannis

aerostar
- 2nd May 2023, 20:13
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.

tumbleweed
- 2nd May 2023, 23:37
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

Demon
- 3rd May 2023, 00:19
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/power/transient-suppression.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

Demon
- 3rd May 2023, 00:27
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

tumbleweed
- 3rd May 2023, 11:49
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.

Demon
- 3rd May 2023, 19:47
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.



... 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

Demon
- 4th May 2023, 02:36
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. :D



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."

tumbleweed
- 4th May 2023, 11:23
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.

Demon
- 4th May 2023, 13:14
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

tumbleweed
- 4th May 2023, 15:34
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.

Demon
- 4th May 2023, 17:39
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

tumbleweed
- 4th May 2023, 19:09
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.

Ioannis
- 5th May 2023, 06:57
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

Demon
- 5th May 2023, 18:47
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.



... 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. :D

Robert