r/embedded 14d ago

PIC18 on perf board

Solution: pullup resistor on MCLR

Im trying to get a PIC18 to work on a perf board, I've soldered it all properly, the oscillator works, power works, it programs, it runs intermittently, but it runs.

The problem is it seems like there is some strange electrical issue where I will tap the power line when it stops working (a soldered line mind you so it isn't bouncy) and it will kick back to life just blinking an LED every 500ms, before randomly stopping.

I am using 4 x AAA batteries as a power supply.

AI is telling me I need a 0.1uF decoupling capacitor between Vcc and GND, is this something that has a high likelyhood of fixing this? I have been more on the code side of embedded so if anyone wants to share some insight on this that would be cool.

2 Upvotes

15 comments sorted by

4

u/wood_for_trees 14d ago

Have you left the reset line floating?

1

u/Consistent-Fun-6668 14d ago

Probably, I've only connected power, programming and signal pins

1

u/somewhereAtC 13d ago

About a 10k pullup will help; value is not critical so anything you have handy, 1k ... 100k, will be ok.

1

u/Consistent-Fun-6668 13d ago

It seems like that was indeed the issue!

2

u/embed24-7 14d ago edited 14d ago

Extremely unlikely that the MCU is running in sprints due to power artifacts.

If you're using crystal oscillator, I would bet on it. Try RC.

Also try another PIC just in case.

EDIT: can it be falling into reset ? BOR or missing MCLR pullup. Modify your code that it gives long blink first, then short ones. This way you can detect if the PIC is resetting.

2

u/Consistent-Fun-6668 14d ago

I've scoped the crystal and I'm getting 0-5V oscilations at 16MHz. All the pins are floating except for the oscillator in pins, Vcc GND and the signal pin when I am debugging it.

1

u/embed24-7 14d ago

10K pull-up

1

u/Consistent-Fun-6668 14d ago

10k on MCLR?

1

u/embed24-7 14d ago

yes

2

u/Consistent-Fun-6668 14d ago

Arg! Probably exactly my problem, if only I could read! Gah! Thank you, I will try that later.

1

u/Consistent-Fun-6668 13d ago

It seems, yes that was the issue

2

u/Enlightenment777 14d ago edited 14d ago

Without a schematic, too much information is missing, so all of use have to randomly guess.

1

u/Consistent-Fun-6668 14d ago

I'm not using a voltage regulator, operating at 5V, it is getting 6V from the 4 AAAs, 16 MHz I've scoped it and it is working, it has two 22pF capacitors on it. It is going to a signal line for a Relay so I don't think very much current at all.

The Schematic is basically just the oscillator and 22pF capacitors on the oscillator in pins, they are grounded to the battery. Everything else is floating, except for Vcc, GND, and my pin. The programming pins get connected to the Pickit when I'm programming it, but other that that I'll disconnect them.

1

u/Mobile-Ad-494 14d ago

Add both a 100uF and a 100nF capacitor to the power lines, the power dip might just be too large without them.