Skip to main content
Associate
April 4, 2024
Question

Help Required: Comparator Interrupt based Time measurement

Hello everyone, this is my first post on ST after starting to use the STM32F072RB on the Nucleo Board. It has been only 3 months since I started working with ST parts, so pardon my missing knowledge and misconceptions. This personal project has been stressing me out too much now, so reaching out to all the amazing brains out here for input, help and support. I am new to STM32, ARM Cortex, STM IDE, and STMCube. Please be nice.. :)

So, I am trying to configure a hardware connection between STM32F072 and a chip that works with parasitic power supply allowing power and communication through a single wire. It is similar to OWS but hacky version of it.

Anyway, I have been able to start the transmission to the slave and I am able to get the response through the hardware and I can see that on the oscilloscope as shown in the image below:

WaseemASheikh_0-1712248567829.png

The blue signal is the power line that shows transmission pulses and the small noise like reception pulses. This response is fed into the hardware that also includes the comparator and the pink/purple signal is the response on PA0, that is the forwarded output of COMP1 to the external pin.

WaseemASheikh_1-1712249221122.png

 


The comparator interrupts are enabled after the transmission is done, before the slave starts to respond. I expect to get 8 bits of data as this is the reset command, and I am getting that on the scope.

WaseemASheikh_2-1712249326692.png

 

I am not really a professional firmware developer or programmer so I struggle whenever there is complicated code involved. The problem I have here is, I am not able to configure the timer such that it stores and resets the value between the pulses. I have a variable in the code say 'response_interval' which I need to store the time value in microseconds between the two consecutive pulses, I have logically written the conversion part of these intervals to binary values (only need to change the comparison numbers maybe).

Long story short, any step by step help to start the timer once the first pulse is received, store the value in a variable, reset the time count and start again, the values of the time could be stored in an array or converted into binary in real time - (which should not be a problem I hope, fingers crossed).

    This topic has been closed for replies.

    7 replies

    AScha.3
    Super User
    April 4, 2024

    Hi,

    for me : information missing : which sensor ?  Signal looks "digital" , so why using comparator ?

    +

    A timer can be set to capture pulse length by itself - but first need more info, whats needed here.

    If you feel a post has answered your question, please click on " Best Answer ".
    Associate
    April 4, 2024

    It is not a sensor. It is an EEPROM.

    The signal back from the slave is a very small transition of 100mV, I do not know a way of digitally isolating a high from low with 100mV of difference, so to 'amplify' it was fed into the comparator to get a strong/nice(r) signal.

     

    Also, I do know the logic, and the implementation of the idea. I am not able to put them in a code. I guess I am not able to understand the timer configuration/trigger and time value storage.

    WaseemASheikh_0-1712253008907.png

    need to capture and store t ^ in a variable, and then continue until the number of bits are done.

    AScha.3
    Super User
    April 4, 2024

    EEPROM  - type ?

    +

    timing pulse/gap for "1" and "0" ?

    If you feel a post has answered your question, please click on " Best Answer ".