PWM / Low Time Measurement Problem

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
KaAs_973901
Level 2
Level 2

Hello, I have attached a project where I am interfacing with an SI 7023 https://www.silabs.com/documents/public/data-sheets/Si7023-A20.pdf humidity/temperature sensor and capturing the PWM signal.

The output is for debugging purposes only.

The issue I am facing is that although I am able to accurately capture the pulse width, I am not able to capture the low time properly with my project. Instead, it seems that the low time is coming back as the period.

I have attached a PWM to the timer in order to simulate the problem. Normally, there is an external device connected to a pin.

I reset the timer after each capture, but am uncertain why I see the period rather than the low time captured.

Thank you in advance for any assistance.

Karl

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hi Karl,

     As said in the earlier post there is an issue with the reset. I have attached the modified project file wherein I have manually reset the timer in software (or loaded the timer's period into timer's counter register) using Timer_WriteCounter(65535) API and the low time is detected correctly.

Regards,

Bragadeesh

Regards,
Bragadeesh

View solution in original post

0 Likes
6 Replies
BragadeeshV
Moderator
Moderator
Moderator
First question asked 1000 replies posted 750 replies posted

Hi Karl,

I'm getting the same issue as you did. The timer is supposed to reset when it has detected any edge according to your design, but it is resetting successfully on rising edge and is not resetting on falling edge. And that's the reason why you're getting the entire period as the low value. I'm trying to find what is the issue with the timer reset. I will get back to you shortly.

Regards,
Bragadeesh

Regards,
Bragadeesh
0 Likes
lock attach
Attachments are accessible only for community members.

Hi Karl,

     As said in the earlier post there is an issue with the reset. I have attached the modified project file wherein I have manually reset the timer in software (or loaded the timer's period into timer's counter register) using Timer_WriteCounter(65535) API and the low time is detected correctly.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

Thank you. To clarify, will there a hardware solution to the reset, or will the software fix be the only option.

Karl

0 Likes

Karl,

There is as such no difference in the two implementations. Ideally, both are expected to work.  For now you can implement this software reset. But meanwhile I will try to figure out the bug in the code and will update it here.

Regards,

Bragadeesh

Regards,
Bragadeesh
0 Likes

The "issue" with the reset might be that the reset signal is processed before the timer is read. Capture and period are cleared to their initial values.

Bob

0 Likes

Bob -

If that's the case, why does the first capture (pulse width) work without issue? Is it luck of the timing?

Looking at the datasheet it does indicate: "It resets the period counter to the period value and also resets the capture counter." with regards to the reset input.

My concern with the software solution is that with the additional cycles taken to reset the counter, some accuracy is lost.. this requires the counter to be set to less than the period to compensate...

Any thoughts?

Thanks,

Karl

0 Likes