# Binary Clock from Highschool, Lost code PIC18f2525

#### stobby

Joined Jun 20, 2018
36
Hi everyone, First time poster here so bare with me. Here's the story Many years ago when i was in my senior year at high school I did a work experience program at a small electronics engineering and manufacturing company. My Task With the boss was to create a 24hr Binary clock Utilizing a PIC micro-controller (18F2525) (28Pin). Now at the time i was confident with construction of simple electronics and SMD boards, However i had and still haven't got any experience with C-programing of these chips. Anyway he showed me some basics of mplab and the standalone Pickit program and did the rest for me.

Now this is about 7 years down the track and i thought i would play with it again only to find the chip is blank.
obviously every circuit configuration is programmed to different I/O's and configs. so i need help with creating the C-code for this circuit. i am using MPLAB X IDE and i have both PICKIT 2 and 3.

The pictures show the project with the red arrow highlighting the MCLR pin. And the Black box highlights the external crystal circuit.
From the Side on photo you can see the LED's are in a Grid formation.
Don't hesitate to ask for more photos or more info, I sincerely appreciate any help, Kind regards Brent.

#### AlbertHall

Joined Jun 4, 2014
11,610
The first task is to determine how the LEDs and buttons are connected to the chip: which pins they connect to; buttons active high or low; LED polarity.

Joined Feb 20, 2016
3,939
You need to draw the circuit diagram. That will be a good excersise

#### stobby

Joined Jun 20, 2018
36
will update with a circuit diagram shortly. In the meantime, there a two things that i cant understand in the circuit.
The crystal oscillator is connected to pins 11 and 12. which don't seem related to an external clock?
secondly both switches are connected to the same source and output to the same location, however i remember them both having different functions.

Will upload circuit diagram Later tonight. Regards Brent

#### bertus

Joined Apr 5, 2008
21,681
Hello,

The pins 11 and 12 are related to the external oscillator:

Bertus

#### Attachments

• 6.5 MB Views: 1

#### ericgibbs

Joined Jan 29, 2010
14,189
hi stobby,
I would say the main PIC clock is an Internal select.
The xtal on pins 11/12 is the T1 osc clock, is it a 32.768kHz xtal.?
E

#### WBahn

Joined Mar 31, 2012
26,398
It's extremely hard to trace very much of the wiring based on the pictures -- and that really is something YOU need to do. So do get that diagram posted.

But it doesn't look to me like the switches are connected to the same pins.

Pins 11 and 12 appear to be for an secondary oscillator. Is it possibly you are using the internal oscillator to run your code and the crystal oscillator as your timebase? I don't know why you would have done that, but that might explain the connections.

#### AlbertHall

Joined Jun 4, 2014
11,610
The secondary oscillator can be used as the CPU clock and might well be for this device as there is at least one second between operations.

Joined Jul 18, 2013
23,937
Hi everyone, First time poster here so bare with me.
We can help, but probably no need to Strip Down!
But 'Bearing' with you it does certainly appear to have a 32Khz Xtal on pins 11 & 12 for a 1 sec TMR1 clock , don't see the customary 22pf caps though.?
Max.

#### AlbertHall

Joined Jun 4, 2014
11,610
don't see the customary 22pf caps though.?
Max.
The caps are SMD on the bottom of the board.

Joined Jul 18, 2013
23,937
The caps are SMD on the bottom of the board.
I obviously didn't read far enough!
Max.

#### AnalogKid

Joined Aug 1, 2013
9,494
Schematic first. With that, you can define the function of each pin. With that, you can define the I/O port configuration registers, and start assigning names to the various I/O pins. Then you are ready to tackle the body of the code.

ak

#### stobby

Joined Jun 20, 2018
36
Hey guys, Some really helpful information above, Once again greatly appreciated. Yea i was assuming the xtal (32khz) had something to do with TMR1. And yes every cap and resistor is SMD other then C-4 illustrated in my schematic which is a 25v 10uf.

There are some bits that might not be correct on the schematic, *1 I don't know what type the transistors are attached to LED's they have no writing on them.
*2 I don't know whether the push buttons are normally open or closed.
For reference the 6 PICKIT pins are at the top of the picture
Thanks again everyone.

#### stobby

Joined Jun 20, 2018
36
And sorry for the delay posting guys, Got distracted with the FIFA

#### ericgibbs

Joined Jan 29, 2010
14,189
hi stobby,
A number of queries on the diagram.
On the photo images where are the transistors.??
E
EDIT:
SMT transistors.??

#### bertus

Joined Apr 5, 2008
21,681
Hello,

@ericgibbs , There seem to be some smd transistors on the right bottom of the second picture.

Bertus

#### ericgibbs

Joined Jan 29, 2010
14,189
Thanks @bertus, I can just make them out, ref last image.
E

@stobby
Created a composite front/back images, so that you can recheck the wiring.
E

Last edited:

#### AnalogKid

Joined Aug 1, 2013
9,494
Recheck the R2, R3, and switch wiring on the board. One end of both switches probably goes directly to either Vdd or Vss. Same for R2 and R3. A shown now, your switches put a dead short on the power supply.

ak

#### AlbertHall

Joined Jun 4, 2014
11,610
I strongly suspect that all the LEDs should 'point' upwards on your diagram.
I strongly suspect that the connections shown for the transistors are wrong.
The usual pinout for those transistors is as shown below. Please check.

#### AnalogKid

Joined Aug 1, 2013
9,494
Reading tea leaves, I *hope* that the reason there are no base resistors is that the three transistors are MOSFETs.

ak