AnsweredAssumed Answered

capture frequency+TRK-KEA128+Code Warrior

Question asked by Vijeendra N on Sep 15, 2015
Latest reply on Sep 23, 2015 by Earl Orlando Ramirez Sanchez

Evaluation board - TRK - KEA 128

IDE - Code warrior, Ver 10.6.4

 

Activity: To capture Square Waves at pin PTC2 using Capture component in process expert

 

Issue: We were getting wrong in correlating the counter register value with the frequency fed at the input pin.

 

Need Support: How to calculate Frequency with the help of Counter register value

And

What is the significance of “maximum time event” and How to set it

 

 

Supporting Data

 

1. Clock Settings

 

2.     Code, I have used example code with small modifications, counter register value will get into variable “result”

 

for(;;)

  {

     if ((Cap1_GetEventStatus(CapPtr) & LDD_CAPTURE_ON_CAPTURE)!=0U){

            Error = Cap1_GetCaptureValue(CapPtr, &Data);

            current_data = Data;

            if(current_data > previous_data)

                   result = current_data - previous_data;

            else{

                   result1 = max_data - previous_data;

                   result1 = current_data + result; 

            }

            previous_data = current_data;

     }    

}

Frequency in Hz

Counter Register Value

100 Hz

43641

200 Hz

54600

300 Hz

14558

400 Hz

60074

500 Hz

48062

1 kHz

24030

5kHz

4803

10 kHz

2401

Attachments

Outcomes