![]() So, assuming you’re dealing with a AC line frequency application with a nominal line frequency of 50 Hz, you should probably plan on a worst-case line frequency of 47 Hz. It is important that you set PRESCALER to a value that will divide the timer’s base clock by enough so the timer’s counter is not clocked at a rate less than 0x10000 times (assuming it’s a 16-bit timer) over the worst-case (longest) period of the signal you want to measure the frequency/period of. SystemCoreClock / (Input capture signal nominal frequency) / (PERIOD + 1) If you want to do an input capture on a signal with a nominal 50 Hz period (sounds like a AC line frequency application, something I’ve had some past experience with ) then you’ll want to set PRESCALER to a value 1 larger than the integer result of: For sake of this discussion, I’ll assume it’s the SystemCoreClock. Generally speaking, the STM32 timers are fed by the system core clock (sometimes, depending on the timer, it can be core clock *2 or /2). Based on this experience, I think I can make a good guess as to what the “PERIOD” and “PRESCALER” values do. I have not used the CubeMX HAL very much but I did recently work on a project that made use of the timer input capture function.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |