Closed trunet closed 3 years ago
Hi @trunet,
Thank you for this detailed report.
Referring to the reference manual, LPTIM can be clocked by an external clock through the LPTIM external input1 or clocked by an internal clock source (APB clock or any of the embedded oscillators). In the first use case, it is necessary to ensure a stable signal for the LPTIM to work properly.
In the other hand, the check on the LPTIM_FLAG_ARROK
is necessary in order to make sure that the period value is well set in the LPTIM_ARR register. Thus, to ensure a correct behavior of your system this check is important so that it is a guarantee that the LPTIM is well clocked and that it is functional.
In order to solve your issue, I suggest you to clock your LPTIM on an internal clock (LptimHandle.Init.Clock.Source = LPTIM_CLOCKSOURCE_APBCLOCK_LPOSC
) and configure the counter to increment at each external event coming from your anemometer (LptimHandle.Init.CounterSource = LPTIM_COUNTERSOURCE_EXTERNAL
).
Hope this would help you to solve the issue.
With regards,
Hi @trunet,
Please allow me to close this thread as no activity has been registered since a month. You can reopen it at any time if you have details to provide us to help you solve this issue. Thank you for your comprehension and thank you once more for your contribution
With regards,
Hi, i am having the same problem with STM32L071, using STM32 CUBE and KEIL :(
I had to add 5 to the initial count
Was there ever a resolution to this issue? I'm trying to put together a very similar project, except with a turbine flow-meter at the front end - no flow, no-go. Same problem here - LpTIM won't start unless there's an external clock up and running. Chocolate teapot in real-world application. We can comment out the error handler in the ARR routine, but it's messy. I've tried various other solutions, to no avail. Next step will be to start the LpTIM in internal clock mode, then see if we can change the input pin once it's started up.
Please, send a e-mail and i will send you my KEIL project (STM32L072) I used to pulse water measure! I am Miguel
tcpipchip@hotmail.com
Hi Miguel,
Thanks for your reply.
A copy of your project would be great for reference. We are using STM_IDE, giving at a go anyway at the start of this new project. Our last big project was done under IAR.
I’m the project manager / hardware designer / team-lead on this one. I’m getting the hardware platform prepared ready before I hand the platform over for serious software dev to begin. LpTIM is the way to go, once we can get it to go.
Thanks again.
John
www.Jlhsystems.co.uk http://www.Jlhsystems.co.uk
From: tcpipchip @.> Sent: 05 August 2023 14:03 To: STMicroelectronics/STM32CubeL4 @.> Cc: JLH64-dev @.>; Comment @.> Subject: Re: [STMicroelectronics/STM32CubeL4] STM32L4 LPTIM as pulse counter of intermittent pulses fails when initialising with no pulse (#24)
Please, send a e-mail and i will send you my KEIL project (STM32L072) I used to pulse water measure! I am Miguel
— Reply to this email directly, view it on GitHub https://github.com/STMicroelectronics/STM32CubeL4/issues/24#issuecomment-1666500462 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BBXQ2XXSREP2J6ES2FMNAD3XTZABLANCNFSM4VICSRJA . You are receiving this because you commented. https://github.com/notifications/beacon/BBXQ2XTGEKBC3MZWCVJBVDTXTZABLA5CNFSM4VICSRJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOMNKMO3Q.gif Message ID: @. @.> >
HI!!!!!!!!! [https://res-h3.public.cdn.office.net/assets/mail/file-icon/png/zip_16x16.png]TXCO.ziphttps://1drv.ms/u/s!Ak_-1v7Ug-k2gZQyB7ZJWiyJGONPew?e=aFYwH2
De: JLH64-dev @.> Enviado: sábado, 5 de agosto de 2023 13:29 Para: STMicroelectronics/STM32CubeL4 @.> Cc: tcpipchip @.>; Comment @.> Assunto: Re: [STMicroelectronics/STM32CubeL4] STM32L4 LPTIM as pulse counter of intermittent pulses fails when initialising with no pulse (#24)
Hi Miguel,
Thanks for your reply.
A copy of your project would be great for reference. We are using STM_IDE, giving at a go anyway at the start of this new project. Our last big project was done under IAR.
I’m the project manager / hardware designer / team-lead on this one. I’m getting the hardware platform prepared ready before I hand the platform over for serious software dev to begin. LpTIM is the way to go, once we can get it to go.
Thanks again.
John
www.Jlhsystems.co.uk http://www.Jlhsystems.co.uk
From: tcpipchip @.> Sent: 05 August 2023 14:03 To: STMicroelectronics/STM32CubeL4 @.> Cc: JLH64-dev @.>; Comment @.> Subject: Re: [STMicroelectronics/STM32CubeL4] STM32L4 LPTIM as pulse counter of intermittent pulses fails when initialising with no pulse (#24)
Please, send a e-mail and i will send you my KEIL project (STM32L072) I used to pulse water measure! I am Miguel
— Reply to this email directly, view it on GitHub https://github.com/STMicroelectronics/STM32CubeL4/issues/24#issuecomment-1666500462 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BBXQ2XXSREP2J6ES2FMNAD3XTZABLANCNFSM4VICSRJA . You are receiving this because you commented. https://github.com/notifications/beacon/BBXQ2XTGEKBC3MZWCVJBVDTXTZABLA5CNFSM4VICSRJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOMNKMO3Q.gif Message ID: @. @.> >
— Reply to this email directly, view it on GitHubhttps://github.com/STMicroelectronics/STM32CubeL4/issues/24#issuecomment-1666506751, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXUZTEC5NAKDDFS3435XY3XTZDD3ANCNFSM4VICSRJA. You are receiving this because you commented.Message ID: @.***>
Hi Miguel.
Yes, I received it thanks and have had a quick look in main.
There’s a big wedding coming up. I’ll get back to you when I have time for a better study.
Thanks again,
John
From: tcpipchip @.> Sent: 05 August 2023 14:59 To: STMicroelectronics/STM32CubeL4 @.> Cc: JLH64-dev @.>; Comment @.> Subject: Re: [STMicroelectronics/STM32CubeL4] STM32L4 LPTIM as pulse counter of intermittent pulses fails when initialising with no pulse (#24)
CONFIRM ME IF YOU RECEIVED
De: JLH64-dev @. <mailto:@.> > Enviado: sábado, 5 de agosto de 2023 13:29 Para: STMicroelectronics/STM32CubeL4 @. <mailto:@.> > Cc: tcpipchip @. <mailto:@.> >; Comment @. <mailto:@.> > Assunto: Re: [STMicroelectronics/STM32CubeL4] STM32L4 LPTIM as pulse counter of intermittent pulses fails when initialising with no pulse (#24)
Hi Miguel,
Thanks for your reply.
A copy of your project would be great for reference. We are using STM_IDE, giving at a go anyway at the start of this new project. Our last big project was done under IAR.
I’m the project manager / hardware designer / team-lead on this one. I’m getting the hardware platform prepared ready before I hand the platform over for serious software dev to begin. LpTIM is the way to go, once we can get it to go.
Thanks again.
John
www.Jlhsystems.co.uk http://www.Jlhsystems.co.uk http://www.Jlhsystems.co.uk
From: tcpipchip @. <mailto:@.> > Sent: 05 August 2023 14:03 To: STMicroelectronics/STM32CubeL4 @. <mailto:@.> > Cc: JLH64-dev @. <mailto:@.> >; Comment @. <mailto:@.> > Subject: Re: [STMicroelectronics/STM32CubeL4] STM32L4 LPTIM as pulse counter of intermittent pulses fails when initialising with no pulse (#24)
Please, send a e-mail and i will send you my KEIL project (STM32L072) I used to pulse water measure! I am Miguel
— Reply to this email directly, view it on GitHub https://github.com/STMicroelectronics/STM32CubeL4/issues/24#issuecomment-1666500462 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BBXQ2XXSREP2J6ES2FMNAD3XTZABLANCNFSM4VICSRJA . You are receiving this because you commented. https://github.com/notifications/beacon/BBXQ2XTGEKBC3MZWCVJBVDTXTZABLA5CNFSM4VICSRJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOMNKMO3Q.gif Message ID: @. <mailto:@.> @. <mailto:@.> > >
— Reply to this email directly, view it on GitHubhttps://github.com/STMicroelectronics/STM32CubeL4/issues/24#issuecomment-1666506751, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ACXUZTEC5NAKDDFS3435XY3XTZDD3ANCNFSM4VICSRJA. You are receiving this because you commented.Message ID: @. <mailto:@.> >
— Reply to this email directly, view it on GitHub https://github.com/STMicroelectronics/STM32CubeL4/issues/24#issuecomment-1666513639 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BBXQ2XROUWROZ3IR5KMRDEDXTZGS3ANCNFSM4VICSRJA . You are receiving this because you commented. https://github.com/notifications/beacon/BBXQ2XXVCAIOH6HGESG2THDXTZGS3A5CNFSM4VICSRJKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOMNKPVZY.gif Message ID: @. @.> >
Describe the set-up
Describe the bug When
HAL_LPTIM_Counter_Start(&hlptim1, Period);
, it HAL_TIMEOUT, unless it's windy or I turn the anemometer with my hand. Note that if it timeout, the read counter is always zero. When it successfully start, even if I have zero pulses in a long time, when there is, it works fine.How To Reproduce
Follow AN4865 and instead of hooking up on a signal generator with stable pulses, connect to intermittent pulses like an anemometer or a rain gauge. All the rest is the same, like LSE clock driving LPTIM.
It will not start the timer with HAL_TIMEOUT, if there's no pulse.
HAL_LPTIM_ReadCounter()
returns 0.Additional context This is probably related to stm32l4xx_hal_lptim.c HAL_LPTIM_Counter_Start function on this code:
If you comment the if block, whenever you have >5 pulses (as the datasheet says)
HAL_LPTIM_ReadCounter()
starts incrementing the pulses.The AN and the datasheet, where it describes LPTIM as external pulse counter, doesn't say anything about LPTIM_ARR register neither LPTIM_ISR waiting for ARROK flag (4th bit).