Many thanks Rob. I have to figure out how to do it. Is the timer working at 
the MCU clock speed?. If so the 16 bit value might be too small to hold the 
pulse length for i.e. a 5 sec pulse, isn't it?. I suppose some prescaling 
should be done there... Have to investigate and read more on that.
Kind regards.
Jes.


El jueves, 3 de septiembre de 2020 a las 18:51:51 UTC+2, [email protected] 
escribió:

> Hi Jes,
>
> I just checked but I was mistaken, there is a procedure that calculates a 
> value for the timer based on a frequency.
>
> If you want to measure the length of a pulse you can use the capture mode 
> of a timer which is available in many PICs, for example the 16F1823.From 
> the datasheet:
> Capture mode makes use of the 16-bit Timer1 
> resource. When an event occurs on the CCP1 pin, the
> 16-bit CCPR1H:CCPR1L register pair captures and
> stores the 16-bit value of the TMR1H:TMR1L register
> pair, respectively. An event is defined as one of the
> following and is configured by the CCP1M<3:0> bits of
> the CCP1CON register:
> • Every falling edge
> • Every rising edge
> • Every 4th rising edge
> • Every 16th rising edge
> When a capture is made, the Interrupt Request Flag bit
> CCP1IF of the PIR1 register is set. The interrupt flag
> must be cleared in software. If another capture occurs
> before the value in the CCPR1H, CCPR1L register pair
> is read, the old captured value is overwritten by the new
> captured value.
>
> Kind regards,
>
> Rob
>
> ------------------------------
> *Van:* [email protected] <[email protected]> namens Jes <
> [email protected]>
> *Verzonden:* donderdag 3 september 2020 13:45
> *Aan:* [email protected] <[email protected]>
> *Onderwerp:* Re: [jallib] Some help needed to measure pulse length 
>  
> Thanks Rob, I look for it, just what I needed to know :0)
>
> El jue., 3 sept. 2020 12:01, Rob CJ <[email protected]> escribió:
>
> Hi Jes,
> I thought there is already a Jal library to measure the width of a pulse 
> created by Matt. Would that do the job?
>
> Met vriendelijke groet,
> Rob Jansen 
> ------------------------------
> *From:* [email protected] <[email protected]> on behalf of 
> Jesito's μFabLab <[email protected]>
> *Sent:* Thursday, September 3, 2020 10:49:48 AM
> *To:* jallib <[email protected]>
> *Subject:* [jallib] Some help needed to measure pulse length 
>  
> Hello, 
> I'm new to JAL and I would like to measure the length of some pulses that 
> can be as long as 5 sec and as short as 1/8000 of second.
> I have a handful of different pics, but ideally I would like to use a 
> small one, I just need one pin for the pulse, two more to interface to an 
> I2C small display and one more to reset and restart the measure.
> Could anyone point me to an example that could guide me through this?.
> I love the cleanless and simplicity of JAL.
> Thanks in advance.
> Jes.
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "jallib" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jallib/29ca65ab-4f67-4e77-a321-9162fd396026n%40googlegroups.com
>  
> <https://groups.google.com/d/msgid/jallib/29ca65ab-4f67-4e77-a321-9162fd396026n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "jallib" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jallib/AM0PR07MB62419C76A4D0F51F787AE7F5E62C0%40AM0PR07MB6241.eurprd07.prod.outlook.com
>  
> <https://groups.google.com/d/msgid/jallib/AM0PR07MB62419C76A4D0F51F787AE7F5E62C0%40AM0PR07MB6241.eurprd07.prod.outlook.com?utm_medium=email&utm_source=footer>
> .
>
> -- 
> You received this message because you are subscribed to the Google Groups 
> "jallib" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jallib/CAJSrQ%3Df1Lm6tHoKCfC4LW68OcQgsKw5FUeGQgaKaiag5oKV8EA%40mail.gmail.com
>  
> <https://groups.google.com/d/msgid/jallib/CAJSrQ%3Df1Lm6tHoKCfC4LW68OcQgsKw5FUeGQgaKaiag5oKV8EA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"jallib" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jallib/a079e103-5ea2-463a-b57d-53ad94caa730n%40googlegroups.com.

Reply via email to