hi can anyone help me i need to calculate the time between 2 rising edge of square wave signal the first signal is relayed with pc10 the second with pc11
that is the schematic :
s14.postimg.org/.../counter1.png
so can u help me plz to modify the code
I did.
thank u bro but can u write it
And you're using what processor?
Not sure if the GPIO method is particularly effective. But you'd want to get a time stamp for the first edge, and then get a time stamp for the second edge. If you know the time of each, you can calculate the difference between them.
wait while PC10 high wait while PC10 low get time stamp t1 ; PC10 now high wait while PC11 low get time stamp t2 ; PC11 now high delta = t2 - t1
Remember to use PRE tags when posting source, make sure you post enough code to see what you're actually doing/configuring.
"thank u bro but can u write it"
Yes, I can.
tks u bro for reply...... hight means 1 and low means 0 or it is false to use 1 and 0 as edge detector ????? other question i do it like that is that correct ???
uint8_t ch[10000]; double timerValue1,timerValue2 ,delta;
do { timerValue1 = TIM_GetCounter(TIM2);
} while(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_10)!=1) ; do { timerValue2 = TIM_GetCounter(TIM4);
} while(GPIO_ReadInputDataBit(GPIOC, GPIO_Pin_10)!=1) ; delta= timerValue2- timerValue1;
} sprintf(ch,"%lf seconde", (double)delta); LCD_SetTextColor(LCD_COLOR_WHITE); LCD_SetBackColor(LCD_COLOR_BLACK); LCD_DisplayStringLine(LINE(9),ch);
What does the documentation for the library say? You've been asked several times about what you're using, I only know what limited context you've provided in the thread.
TIM2/TIM4 why different timers?
http://www.keil.com/forum/tips.asp
the first timer is used to calculate the first rising edge the other timer used to calculate the second rising edge but it does not work because it calculate only the first do{} while ;
You are aware that a single chronograph can be used to take quite a number of intermediate times when you have a runner doing a 10000m run?
It's just that you don't seem to have considered yet what it means to either start/stop a timer. Or to have a free-running timer and just take multiple snapshots and compute the difference between the snapshots. So start thinking about how you could use a single clock to both measure the total time that runner needs for 10 km running. And how you can manage to figure out each individual lap time. Or maybe each individual 1km section time.
You will fail again and again until you stop playing around and start to think about what the timer actually does. Stop thinking that the timer magically starts being in existence the moment you start to sample values. And by the way - you don't even need to capture values continuously within the loop, since it's enough to capture the value directly after you found the condition change that means you want to exit.
In the end, trial and error really is not a good route since it's so very slow. That's basically what evolution does. So trying millions of small biological changes over hundreds of generations to try to figure out if some changes might lead to an improvement or not. It's just that trial and error (in science also sometimes discussed as Monte Carlo methods) means you need a huge number of dices to be able to test enough random solutions concurrently - just to get some decent progress.
Keil continues to run this forum like fools. I can't use the word "s t o p w a t c h" without getting error 500 when trying to post. Just as this forum constantly fails to accept posts relating to "w a t c h d o g". Who thinks it's clever to filter these words on a forum specifically related to embedded development??? I have also notified their support but they don't seem to be able to figure out why anyone might want to legimitely want to use the word "w a t c h" without intending it as spam.
How old are you?
How many w atches would you need to time your trip between your home and the closest town?
What processor and board are you using?
watch
stopwatch
Just use a little imagination
Imagination? The word "chronograph" in my earlier post was "stopwatch", but without any character in bold.
New posters who come here and get error 500 when they try to post will not be able to use any imagination to modify their post since they will not know that status code 500 is a badly tuned spam filter. All they want is help, and they'll leave when they can't post. And you'll never know because you never see their post. And Keil'll never know because they don't analyze the blocked posts.
All they want is help ...
All anybody wants is that occasional piece of help.
If you are using a STM Board there may be a example available with a name like
TIM_InputCapture that programs a timer to operate in input capture mode. And use
a timer interrupt to capture the time a pulse comes in. The next interrupt that occurs
because of another input pulse will cause a calculation of the time between pulses.
I am looking at STM32F_100E_EVAL board. They calculate but it also says that the frequency
maximum it can resolve is around 330 khz.