cancel
Showing results for 
Search instead for 
Did you mean: 

Too slow for Input Capture? 1Hz

john doe
Lead
Posted on July 19, 2017 at 14:17

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?

13 REPLIES 13
Posted on July 22, 2017 at 18:27

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

Posted on July 22, 2017 at 20:19

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

Posted on July 22, 2017 at 20:33

0690X00000603xoQAA.jpg

This procedure can also be done by hardware by select to work with PWM input mode at an appropriate timer

Posted on July 30, 2017 at 16:44

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-2000

RTC Alarm A - 00:30:00  1-1-2000

RTC Alarm A - 00:31:00  1-1-2000

WWVB Frame received: 0x3084410946138C0

11:03 UTC  Day 211 of 2017

DUT1 +0.3   DST: Yes   Leap year: No   Leap second: No

Local time: 06:04 AM  Sunday July 30, 2017

RTC Updated - 06:04:00  7-30-2017

RTC Alarm A - 06:05:00  7-30-2017

RTC Alarm A - 06:06:00  7-30-2017

RTC Alarm A - 06:07:00  7-30-2017

RTC Alarm A - 06:08:00  7-30-2017

RTC Alarm A - 06:09:00  7-30-2017

WWVB Frame received: 0x8084410946138C0

11:08 UTC  Day 211 of 2017

DUT1 +0.3   DST: Yes   Leap year: No   Leap second: No

Local time: 06:09 AM  Sunday July 30, 2017

RTC Updated - 06:09:00  7-30-2017

RTC Alarm A - 06:10:00  7-30-2017