Hi,
I'm new with the CC2540 F256, I want to measure the pulse frequency of a square wave in an input pin. Do you have any suggestion, where can I start?
Thank you in advance
Igor
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hi,
I'm new with the CC2540 F256, I want to measure the pulse frequency of a square wave in an input pin. Do you have any suggestion, where can I start?
Thank you in advance
Igor
Hi,
You have two ways to do it:
A good place to start is by getting familiar with "cc253x/4x User's guide" section7, and
one of the timers (Timer1, Timer3, or 4).If you have any other questions, just search in
the forums (there are a lot of topics discussed here, especially "I'm new with" topics)
Igor,
There are two ways of doing this. Measure the signal frequency or measure the period.
In the first instance you count number of input pulses during a fixed interval. E.g. set measurement interval to 1 msec and if you counted 14,100 pulses during this period your input frequency is 14.1MHz. This works for high input frequencies. It usually requires using a hardware timer in counter mode. I am new to CC2540 and 8051 core so please check that this mode is available. Also, use the timer that is not used by OSAL or other parts of the framework.
To measure relatively slow input frequencies you calculate the input pulse period and derive the frequency. This is done by using one of the system timers in input capture mode to get the number of system clock ticks between two rising edges of your input signal. E.g. with timer timebase 32MHz and input period capture of 12800 your input signal frequency is 2.5kHz.
If you are new to these techniques just search internet for detailed explanations. When you decide what you need to do use CC2540 User Guide (SWRU191C) chapters 9 and 10 for details how to do it on CC2540.
Leo
HI,
thank you some much for the both answers.., i will follow your advices, if i will have some problem else, you will hear again about me LOL
Regards,
Igor
hi again,
i have selected T1 for capturing the edges of my input signal(square wave), and i dont get anything because i think that the operation system OSAL used it. So i try with the T3
so i select a pin as input, as peripheral function
P1DIR &= ~(1<<4);
P1SEL |= (1<<4);
and then
T3CCTL1 = 0; //RESET
T3CCTL1 &= (0<<2); //capture mode
T3CCTL1 |= (1<<0); //rising edge
T3CTL |= (6<<5) | (1<<4); // freq selected 32Mhz / 64 = 500Khz for measuring aprox 160k HZ so enough. and then START counting
so the problem is that I always an overflow and the same value, altough the input freq change.
Another question: When i get a T3CH1IF (what means the capture is finished?), does it mean that he measured the cycles between two edges of my input signal? Or does he count for a defined period?
Igor