2010-06-28 04:09 AM
input capture problem with stm32
2011-05-17 04:56 AM
Try replacing:
while((TIM3->SR & TIM_FLAG_CC2) != TIM_FLAG_CC2);
with:while((TIM3->SR & TIM_FLAG_CC2) != RESET);
in two places. Also - what range of frequencies are you trying to measure? Waiting for a printf after the first capture compare will limit your upper frequency. Cheers, Hal2011-05-17 04:56 AM
Meanwhile, thanks for your interest.
I just tried but nothing has changed.
Always gives me zero frenquenza.
The signal I am simulating a frequency of 200Hz.
Ok take out the printf.
Overall missing a configuarazione to do?? All the code I wrote in first post
2011-05-17 04:56 AM
anyone can help me????
2011-05-17 04:56 AM
I will try....again.
The program may have locked out the interrupt. You enabled an interrupt, but as far as I can tell here, you did not clear the interrupt in an IRQ handler. See the vectors.c file int the STM library TIM examples for IRQ handler programming. The IRQ handler is a good place to read the capture register, since the interrupt has just occurred. Your main.c can then printf without disturbing the capture timing. Cheers, Hal2011-05-17 04:56 AM
Hello Cheers Hal, thank you very much for your help.
I did not understand what to do with IRQ handler sorry but this is the first time I make this type of programming and not the ST is helping me.
You think that there can be blocked interrupt? Stm32f10x_stdperiph_lib From the examples I see this call enables interrupts by ''TIM_ITConfig (TIM3, TIM_IT_CC2, ENABLE);'' and then configure the nvic through this function call
NVIC_Configuration void (void)
(
NVIC_InitTypeDef NVIC_InitStructure;
/ * Enable the Global Interrupt TIM3 * /
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init (& NVIC_InitStructure);
)
I do not know what to do, I'm going crazy the brain.
Do not have a working code sample so I can understand how and what to do?? I searched throughout the forum but have not found anything that can help me.
Thanks again for your help
P.s.= i've found vectors.c but didn't help me :S2011-05-17 04:56 AM
STM has provided an example that does what you are trying to do. Go to the STM32 Downloads section and make the following selections:
Downloads Documents and Files Firmware STM32F10x_StdPeriph_Lib Download the library to your computer, and then make the following selections in the library directories: Project STMF10xStdPeriph_Examples TIM Input Capture main.c and stm32f10x_it.c main.c sets up the clocks, NVIC, timer interrupts, etc., then goes into an idle mode. stm32f10x_it.c contains the IRQ handler which services the interrupt, then computes the frequency. If you wish to print out the frequency at some interval, you should add that to main.c as I stated in an earlier post. This should get you going. A votre sante ! Hal2011-05-17 04:56 AM
Your interrupt handler name is different from the standard peripheral library example. Perhaps your development environment TIM interrupt vector is pointing to a different interrupt handler.
Cheers, Hal2011-05-17 04:56 AM
2011-05-17 04:56 AM
Ah ok then it must have the same function name in the library?? Did I call it differently to avoid confusion.
But I must call the main function or not?? Thanks again for your help