Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/16/06 12:28
Read: times


 
#118407 - Measuring frequency clock input LPC931
Hello,

For my project I am using a P89LPC931 from Philips. The program is running on the internal clock frequency (7.3728MHz). The LPC931 gets an external clock signal (below 7MHz) on the XTAL1 input. I want to determine the clock frequency of this signal. Can I do this with help of the real time clock? I want to run the processor on the internal RC clock and the RTC on the external clock. Is this possible or is it only possible to use an external crystal for the RTC? I use the code below, but the value of TempCount is not the same with the same frequency on XTAL1. It differs a lot and I can't determine the frequency. Do you know if I can fix this problem and how?

Kind regards,
Mark


unsigned short MeasureClockfrequency()
{
	unsigned short TempCount;
	EA=0;
	//Make sure RTC is disabled to make it possible to write to RTCH, RTCL and other bits of RTCCON
	RTCCON = 0x00;
	// set reload value
  	// count frequency = clock source / 128 / RTCH,RTCL
  	RTCH = 0x00;
	RTCL = 0x2F;	

	TempCount=0;
  	// select External crystal oscillator, disable interrupt source
  	RTCCON = 0x00;

	// start real time clock
	RTCCON |= 0x01;

	while (!(RTCCON & 0x80)) TempCount++;

	// clear RTCF interrupt flag and stop the real time clock
	RTCCON &= ~0x81;	
	EA=1;

	return TempCount;
}


List of 6 messages in thread
TopicAuthorDate
Measuring frequency clock input LPC931            01/01/70 00:00      
   Update of the code...            01/01/70 00:00      
   what does "below" mean            01/01/70 00:00      
      below 7MHz            01/01/70 00:00      
         of course            01/01/70 00:00      
            thanks            01/01/70 00:00      

Back to Subject List