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.

PSoC Frequency Measurment

Status
Not open for further replies.

bassplayer142

Newbie level 5
Joined
May 28, 2006
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,350
Hi everyone. I'm trying to determine the frequency of a incoming signal at roughly 7KHz. This signal is correctly identified using a scope and is at correct logic levels. I am using the 16bit Tachometer digital block which adds a second interrupt. It is basically a 16 bit timer with the added interrupt. I have a 1MHz input clock which should get me enough resolution for this. The incoming frequency is fed into the capture port on the block. Now I'm having trouble getting a frequency measurement. Here is some of my code.

Code:
void main(void)
{

LCD_1_Start(); 						// Initialize LCD hardware

TachTimer16_1_WritePeriod(0xFFFF);
M8C_DisableGInt;
TachTimer16_1_Stop();
TachTimer16_1_EnableInt();
TachTimer16_1_Start();
M8C_EnableGInt;

	while(1){
	
	
	LCD_1_Position(0,0); 				
	lcd_int(diff,5);

	freq = (0.000001)*(0x10000-diff);
	
	delay();
	TachTimer16_1_WritePeriod(0xFFFF);	
	TachTimer16_1_Start();
	delay();
	}

Code:
void MyCounterISRLSB(void)		//capture interrupt
{
	to = TachTimer16_1_wReadTimer();
	
	if (to < tf) diff = tf-to;//(0xFFFF-tf)+to;
	else diff = ((0xFFFF-tf)+to);
	tf = to;
	
	
	TachTimer16_1_Stop();
}

I am getting the decimal value of 2222 for "diff" which stays consistent with the frequency at 7.3KHz but can't seem to figure out how to get this value in frequency form. I have searched hours for this and haven't gotten much of anywhere. Any help is greatly appreciated.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top