Skip to main content
Visitor II
November 6, 2023
Question

LPTIM count error on STM32L476RG

  • November 6, 2023
  • 2 replies
  • 4185 views

Hello,

I am experiencing counting errors (specifically overflow counting errors) on LPTIM1.

A bit of context first: the goal is to use the LPTIM1 to count pulses which are first treated by the COMP1 (to convert the input signal into an all-or-nothing signal).

The first round of testing was realised with an external source of power as COMP1's voltage reference (minus input), and there was no issue with the overflow count (which is necessary to allow counting continuity). Thing is: the final board has to be completely autonomous and use as little resources as possible, including the sources of power.

So, the idea was to switch to the DAC as COMP1's voltage reference. Since I've done that, the overflow counting isn't incrementing any more, and the pulse count is wrong. Another round of testing - this time routing COMP1's minus input to an external pin - revealed that if the program is initialised on the external power source, and then switched to the DAC's output, the counting works just fine. But, if the program is initialised with COMP1's minus input on the DAC output, it doesn't work at all (even when replugging the external power source later on).

I have no clue on how to fix this weird behaviour, so here I am.

Thanks in advance for the help.

    This topic has been closed for replies.

    2 replies

    ST Employee
    November 6, 2023

    Hello @afacerias,

    I am sorry for your bad experience with our products. Just to be sure, have you checked the device erratasheet, specifically points 2.8.1 and 2.8.2? (link) What is the configuration of PA4 and PA5 pins?

    BR,
    Jaroslav

    afaceriasAuthor
    Visitor II
    November 6, 2023

    Hi, the link you shared returns a 404 Error... :\ But I have read it before.

    Nonetheless, PA4 is in Reset_State and PA5 is DAC_OUT2.

    ST Employee
    November 7, 2023

    Hello @afacerias,

    you are right, sorry, I inserted the address two times. It should be OK now.

    Anyway back to your issue: have you checked the outputs of the DAC and COMP on a scope?

    BR,
    Jaroslav

    ST Employee
    November 7, 2023

    OK, so the input to the LPTIM is in both cases the same, but the pulse count (CNT register) and interrupt generation on ARR match are corrupted?

    Could you share with us some simplified code with this wrong behavior?

    Thank you,
    Jaroslav

    afaceriasAuthor
    Visitor II
    November 7, 2023

    Yes, the input to the LPTIM is the same in both cases.
    Here are the code files I work with.

    Thank you for your help.