2012-03-28 08:29 AM
I wonder if someone could help me.
I want to count the number of pulses occured each ''x'' time. I could use a timer configured to generate an interrupt each ''x'' time. And the interrupt handler of this timer should read the counter value, and reset the counter. But, if the processor is executing a non-preemptive task while an interrupt will occured, the processor will execute the non-preemptive task until the end, and the interrupt handler will wait until the non-preemptive task will be completly executed. But meanwhile, some pulses can occured and will be counted. So, I would ask if I could avoid this situation with a timer in Input capture mode. Is it possible to configure a timer in Input capture mode, using as Active input an internal periodical timer, instead of an input pin channel, and using the input pin as counter clock, instead of internal clock? I mean, I would like to have an internal timer that generates the capture event cyclically, meanwhile an external pin clocks the counter. After each capture I would use the DMA to store the captured value to a global variable. If it is possible, could someone tell me how I could make it working? (procedure, configuration, registers to modify) I would also o ask if it is possible to cascade a timer in Input Capture mode. Because, the external signal has a 1Mhz max frequency. If I will generate capture events only each second, the capture counter will overflow before one second. Thank you very much, Best regards, A. Paiva #stm32-pulse-counter2012-03-29 10:05 AM
I'm developping a controller for general applications in my company. I'm developping only the low layers,
I would known if there is another solution, to make this, without losing data. If there is, why should I use not accurate data? If there isn't then I must use this solution.
so, here is the problem you want to develop something withoout knowing a) if a RTOS is involved b) if an accurate reading for time x is enough even if a few pulses are lost between slots c) if a highest level interrupt can be allowed more than minimum cycles there is no ONE solution regardless of everything else Erik
2012-03-29 10:32 AM
You have right.
And that is the reason why I want to know the other solutions! I want to gather as much information as I can on this step, to subsequently know which of the solutions I will apply, when I will known the process to control. At this step, I will understand how the device works, how to configure it, and find all the possibilities I have, to subsequently take the best. Best regards, A. Paiva2012-03-29 10:44 AM
I think one of the problems here is that 16-bit general purpose timers are ill-suited to applications with MHz clocks, and indeterminate interrupt latency.
One would typically use specialized hardware (CPLD/FPGA) with 32-bit counter/timers, capable of latching counts at hard sample points. ie where the performance is explicitly implemented in the hardware, by design. Now you might be able to fashion the general purpose timers to your own purposes, but it will require that you do A LOT of reading and analysis of the timer models and connectivity, and A LOT of experimentation with the hardware. I don't think you can escape doing you own due diligence here.2012-03-29 11:15 AM
Thanks both of you.
And I'm sorry if I'm much currious. I'm starting right now with this devices, and maybe it is more complex then I think. I'm in a starting level. I've written here because I think that this kind of forum is used to share experiences that aren't written in reference manuals, or other datasheets, or firmware examples. It's also a challenge, make something working in a different manner, as the traditional form. And this makes things evaluate. Am I wrong? Clive, you have right that a FPGA would be able to make this over hardware. But ok. Forget my application. Can someone tell me for what is, CC1s configured as ''11'', used? Thank you, A. Paiva2012-03-29 11:36 AM
maybe it is more complex then I think.
why do you think RM0008 is 10MB? <i>Can someone tell me for what is, CC1s configured as ''11'', used?</i> you need to be more explicit: register name and bin/oct/dec/hex, RM0008 chapter and verse would be good too Erik
2012-03-29 11:39 AM
you need to be more explicit:
also STM32 WHAT, there are differences between the STM32 families
2012-03-29 11:49 AM
Am I wrong?
Probably not, but the forums are generally full of people who really don't know what they are doing, or how to ask/pose detailed questions. ie the blind leading the blind. I'm not sure how much out-of-the-box thinking you're going to get, but I do understand what you're looking for. That's not to say there aren't some smart people here, but they are in the minority. There are some timer example that work well, and can be clearly illustrated. However the timers are very complex, and lack a lot of examples and documentation, including HW models. Personally I wish ST would provide a far more comprehensive set of examples. Perhaps even a wizard tool where you can chain/configure timers, and supply input stimulus, and experiment with all the modes. I also find the 16-bit model to be too limiting, and the chaining to add to many atomic access issues. They are probably fine for people dealing with a few dozen KHz.2012-03-29 12:37 PM
Thank you Clive!
''but the forums are generally full of people who really don't know what they are doing
'' This is because much of this people don't know how to use this tool called ''forum''. It could be a powerfull tool, if people who has questions, or curriosity post questions, and people who has lot of experience, or very smart people, share knowlege.''There are some timer example that work well, and can be clearly illustrated. However the timers are very complex, and lack a lot of examples and documentation, including HW models
''
Yes, you have right. You have some families, but the examples are always the same, and the datasheet explain always the simple examples. Why did someone make so powerfull devices, but then explain only the simple features? (The features that a simple uC also can do) If a device has other features, registers, and configurations, in my mind, this should be the main contents focused on documentation, and also on examples. Thank you very much. Best regards, A.Paiva
2012-03-29 12:51 PM
Hi Erik,
I told you before. Reference manual RM0090, September 2011, DOC ID 018909, Page 401 (for example). I posted before that I'm refering toTIMx_CCMR1 register. And I would to know in which kind of application, the CC1S bits is configured as ''11'' (binary).
See attached file. Best regards, A.Paiva ________________ Attachments : Capture_compare_channel.png : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtWr&d=%2Fa%2F0X0000000aRK%2F0bwOTP7pyGyFW8S9xS0go9ggAFWl66.QqXTPtCzrPl8&asPdf=false2012-03-30 06:41 AM
well, I did not ask ''which manual?'' I asked ''which chip?''
Erik