Continue to Site

Welcome to

Welcome to our site! is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Oscillator problem, long tracks, High speed crystal

Not open for further replies.


Member level 1
May 5, 2011
Reaction score
Trophy points
Activity points
Hi all,

I'm using a PIC18F4520 to control a matrix of LEDs (144 nos.) 16 x 9 configuration (PORT B and D for positive, available pins of port A and C for negative). The oscillator is a 32Mhz crystal (I tried an 8MHz too). The board is fairly big (20 inches by 12 inches) so the tracks are long and all over the place. I'm not using and latches or resistors. I know my design is not the best :p

The board dosent seem to work! I feel that the first few lines of code work and somehow it gets reset. I've disabled WDT and brown out. This is the first time I've designed such a large board, I've designed and used small boards with PICs without any issues.

Any help and advice is appreciated.


I have some update on this. I got the board to work, all the LEDs work but they kind of flicker, no idea if its because of track capacitance or because of reset or because of oscillator. When I put my hand on the board (di-electric) it stabilizes a bit but the fix is quite random, works sometimes doesn't work sometime. This is just to give the wise guys as much dumb info as I can to help me, of course we want this to work without giving my hand with the board :p

I replaced the crystal with a 4Mhz, better but still resets after a few seconds :(

How did you connect the MCLR pin of your uC? How long are the tracks between your crystal and uC? Do you have decoupling capacitors placed at every IC's power pins?

Post the image of your pcb so that we can discuss, or this thread will look like monologue.

Thanks for you time zasto.

The MCLR is connected to +5v through a 1K resistor. In process of debugging I connected the crystal directly to the Pins of the PIC. I do have a .1 uf decoupling cap for the PIC. I'm attaching an image taken from my phone, very poor quality but may help you get a sense of size.

Also when I do a debug run using ICD2 it all works fine...

I had similar problem with a fewer number of LEDs. That much LEDs can draw a lot of current and cause a voltage drop in turn resetting the MCU.

make sure your power supply deliver enough juice for all circuit to perform correctly. and separate microcontroller power supply track and LED track. bypass it with 0.1uf and 10 uf capacitor...good luck

I tried the 10uf, I think it works a bit longer before getting reset. I'll try to get a better 5v power supply and try with that, currently it working off a 7805... do you think that could be the issue? Also track width, what should be the recommend width?

erio the LEDs are connected to the PIC pins as and array (16x9) but the power is only to the PIC... do you think I need to change something? I didnt get the bypass .1uf 10uf also, forgive me being really dumb.

Thanks for helping out guys, I really appreciate it.

are you sourcing/sinking LED current with PIC? maybe this is your problem. try adding transistor for driving the led matrix.

well any schematic of your project make things more clearer...good luck

Yes I'm sourcing/sinking directly with PIC! You advice I use something like a ULN2003? What exactly would you suggest for anode and cathode sides?

well BD140 on the positive side and ULN2003 on negative side will do the job...
note the data must be inverted..good luck

PS: do this on the breadboard before changing PC board.

You can sink/source 25mA on a PIC pin. But it sums up when you use many pins, and it overwhelms the Vcc pin (I think it's also 25mA).
Beside the track width, avoid using long and/or thin power cable (for example if you're powering from the USB port).

thanks guys, I'll make changes, test and update you all. @bjuric I can use additional wires to overcome the track width to the PIC Vcc and Gnd but to do it for all the LEDs would not be possible now as the boards have been produced already, do you think thats would do the trick?

It should do the trick, as long as you have the power with enough juice, and good cable from the power supply to the board.

It would be an equivalent of what 'erio' suggested in post #8 (separate tracks for the PIC). After all, try that. It's only a few seconds work.
But driving all the LEDs from the PIC would still be an issue (try to squeeze in the transistors as 'erio' suggested). Don't forget to put the capacitors close to the Vcc pin ;)

If your LEDs start to dim when more are turned on, you'll have to reconsider the track width anyways. Since the boards are already made, you could solder the wire along the tracks, but it would be a very dirty solution.

I'm going with the advice... plan to put together addon board with ULN2803 x 2 for the -ve side and BD140 x 9 for +ve. I'll try to finish this in the next 24 hours and write an update

Well it works!! Thanks guys... I still have a lot of work to do on the software side and one row of 9 LEDs is still not working, infact if I connect that row the whole thing resets (any ideas there??) But the board works, thanks everyone

Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to