Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com 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.

How to check the clock frequency using software

Status
Not open for further replies.

chethankp

Member level 4
Joined
Jan 4, 2010
Messages
76
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
bangalore
Activity points
1,860
Hi,
I have connected 16MHz crystal to micro controller, now I want check this clock speed using software .

i.e I want to verify in which speed micro controller is runnig in case of the crystal is not connected.

I have written small code to check this : I was verifying this on oscilloscope
while(1)
{
delay ();
P1=1;
delay();
P1=0
}

Due to While loop it was difficulty to set the duty cycle .


is there any way to implement this..?
 

I assume that you connect the crystal as a system clock source, in that case if the crystal malfunctions in any way (broken, disconnected etc)
the system will be frozen, without a system clock no instruction is executed.
The only self calibrating system i have seen is when there is an internal system clock source and a second external clock source is used (an external 32.768Khz crystal) for real time clock,
in that case the small crystal can be used to calibrate the internal clock frequency to a certain accuracy.
The code you have written will output a 1 0 1 0 square wave to P1 but the frequency will be much lower compared to the clock because there are a number of instructions involved which consume time,
the duty cycle should be 50% since the instruction are the same in both states (same delay).

Alex
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top