Not sure whether your microcontroller supports CAPTURE feature. Just found a Chinese datasheet.
Most accurate approach:
* set up a 16bit timer/counter to count with 1MHz
* use CAPTURE method on both edges
* calculate CAPTURE_Falling - CAPTURE_Rising
Not sure whether your microcontroller supports CAPTURE feature. Just found a Chinese datasheet.
Most accurate approach:
* set up a 16bit timer/counter to count with 1MHz
* use CAPTURE method on both edges
* calculate CAPTURE_Falling - CAPTURE_Rising
questions like:
* "is there anyone has experience with FMD MCU?"
* "can you help me?"
are useless. They just make the thread longer and longer.
--> just provide all informations about your situation
--> then ask detailed, elaborated questions.
Informations we need:
* a link to an English datasheet
* your IDE, language, compiler
* your SW approach. At least a flow chart ... or a clear description. A sketch often is better than a lot of words.
* what is clear so far?
Question:
* what exactly is the problem?
****
We don´t know whether you never had a resistor in your hand ... whether you are experiened in programming, ...whether you have difficulties in understanding
datasheets.
We can´t replace school. We won´t do the whole engineering job for you.
But we can help you rectify some detailed problems.
You need a sync to start/stop 12 bit time interval counter on positive duration, with other 8 bit timer for any other purpose such as a digital FLL or as a prescaler for 20 bit counter.
If you do not have a design spec, you cannot design.
questions like:
* "is there anyone has experience with FMD MCU?"
* "can you help me?"
are useless. They just make the thread longer and longer.
--> just provide all informations about your situation
--> then ask detailed, elaborated questions.
Informations we need:
* a link to an English datasheet
* your IDE, language, compiler
* your SW approach. At least a flow chart ... or a clear description. A sketch often is better than a lot of words.
* what is clear so far?
Question:
* what exactly is the problem?
****
We don´t know whether you never had a resistor in your hand ... whether you are experiened in programming, ...whether you have difficulties in understanding
datasheets.
We can´t replace school. We won´t do the whole engineering job for you.
But we can help you rectify some detailed problems.
MCU is FT60F211
then it has timer2 as 16bit
compiler is FMD IDE
I want to measure just high pulse width using timer2 as counter can you help me in code?
Any chance you can paste code into word and use google translate to
change comments to english ?
If you are trying to measure PW basically enable a counter to run with
transition from low to high on input pin, it then counts while pin is high,
then when pin goes low counter stops, the - edge of pin triggers an interrupt,
interrupt reads counter value, and resets counter.
The period is counts x counter clock period. So if clock was 1 us, and counter
read was 10, then PW = 10 uS.
You typically pick a clock so that at smallest PW you want to measure in the
counter will take ~ 5 clocks minimum. The more the better, because that
makes more accurate the reading. But you tradeoff counter size because
as you seek finer resolution, higher clock freq, counter must get bigger to
read the widest PW in you want to measure.
Now lastly you have to take care of counter overflow for an out of range input.
So another isr for a carry out triggered interrupt will tell you its overflowed and
you have to add to final PW counter read the max count value of the counter
to get accurate reading.
In your ISRs best practice is to set a flag and return to main code to process. You
want in general to not call f()'s in ISR because that creates a lot of stack push saving
variables before the f() is called. It also wastes CPU time. Also declare variables used
in ISR as VOLATILE, google this for explanation why thats needed. Also google good
ISR coding practices......
Regards, Dana.
--- Updated ---
I want to use FT60E211 to measure high pulse width range 150us to 25ms
is there an example?
What accuracy do you want to do this to ? What size are the counters in this part ?
Do you have a datasheet link for this part, that you can post here, hopefully in English
or use a utility on web to translate it.