2017-07-19 05:17 AM
Looking to measure duty cycle of a pin where I'm looking for a pulse anywhere between 200miliseconds and 800 miliseconds on a 1Hz period. I think I used the terminology correctly, sorry if I didn't. Much of the time, the pin could be ringing with a lot of noise, rather than a good solid pulse. It is a WWVB receiver/decoder.
It seems like the counters might be rolling over before my input period ends, so I would have to slow down the clocks. I think.
I could probably just use GPIO and external interrupts, and simply count ticks between them.
Your thoughts?
2017-07-22 11:27 AM
I'm having a little trouble with the algebra -
I'm using an Nucleo F446RE where HCLK is configured to 180MHz and APB1 Timer clock is at 90MHz
With TIM5 free running with prescaler of 1 and arr of 0xFFFFFFFF
I'm having trouble with the formula to reconcile time between increments of the CNT register and its relationship to milliseconds
I keep scribbling on this wet cocktail napkin and the bartender keeps laughing at me
2017-07-22 01:19 PM
hello!
fact: APB1 Timer clock is at 90MHz
with presc=1 every ms is 45000 counts
with presc=0 every ms is 90000 counts
with presc=8999 every ms is 10 counts
2017-07-22 01:33 PM
This procedure can also be done by hardware by select to work with PWM input mode at an appropriate timer
2017-07-30 09:44 AM
While I did not get it working the way I intended, I did get it working. Somewhere along the way, I swear it was you, someone pointed out that instead of measuring the pulse i should be measuring the low time between the pulses. it occurred to me that this method would be more tolerant of noise. I have not done it that way yet, but for now, I have working code that sets the rtc! I ended up using a 32 bit free running timer and EXTI. Thank you so much for your help!
RTC Alarm A - 00:28:00 1-1-2000
RTC Alarm A - 00:29:00 1-1-2000RTC Alarm A - 00:30:00 1-1-2000RTC Alarm A - 00:31:00 1-1-2000WWVB Frame received: 0x3084410946138C011:03 UTC Day 211 of 2017DUT1 +0.3 DST: Yes Leap year: No Leap second: NoLocal time: 06:04 AM Sunday July 30, 2017RTC Updated - 06:04:00 7-30-2017RTC Alarm A - 06:05:00 7-30-2017RTC Alarm A - 06:06:00 7-30-2017RTC Alarm A - 06:07:00 7-30-2017RTC Alarm A - 06:08:00 7-30-2017RTC Alarm A - 06:09:00 7-30-2017WWVB Frame received: 0x8084410946138C011:08 UTC Day 211 of 2017DUT1 +0.3 DST: Yes Leap year: No Leap second: NoLocal time: 06:09 AM Sunday July 30, 2017RTC Updated - 06:09:00 7-30-2017RTC Alarm A - 06:10:00 7-30-2017