Chime PWM output cutoff

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.
Anonymous
Not applicable

I have a side project where I am sending frequencies to a speaker (chime) component, but I am getting some strange results. Rather than hearing the chime pattern as I have defined, I am only hearing the first couple frequencies and then it cuts off completely for the remaining length of the period.
I used a logic analyzer and saw that the signal is indeed being cutoff (see attached photo). I should be seeing various frequencies over the course of 2 seconds, but am only seeing the first 0.1 s or so. Just for testing purposes, I tried only writing one frequency for 2 seconds, and it was working fine.
It seems as though the PWM component does not like changing period/compare values, or something else is going wrong. I've attached my project as well as some screenshots.
Thank you!

0 Likes
1 Solution
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Please try calling - "ChimeOutput_SetCounter(0);" after setting the period and compare value.

As your period value is decreasing in nature and you have not synchronized the period update to the start of the PWM, it might result in you setting the period value to a lower value than the current counter value. In this case, the counter keeps counting up till it reaches 0xFFFF and then rolls over and then count. By this time you would have changed/reduced the period even further and if the sync is gone again, you will never see the PWM output.

In order to ensure this does not happen, every time you set the period, please clear the counter by setting it to 0.

Let me know if this helps - I have not tested it but this comment is more from your description and a quick look at the main. So I hope thats the issue. otherwise will try it out in a kit

Regards,

Meenakshi Sundaram R

View solution in original post

0 Likes
1 Reply
MeenakshiR_71
Employee
Employee
100 likes received 50 likes received 25 likes received

Please try calling - "ChimeOutput_SetCounter(0);" after setting the period and compare value.

As your period value is decreasing in nature and you have not synchronized the period update to the start of the PWM, it might result in you setting the period value to a lower value than the current counter value. In this case, the counter keeps counting up till it reaches 0xFFFF and then rolls over and then count. By this time you would have changed/reduced the period even further and if the sync is gone again, you will never see the PWM output.

In order to ensure this does not happen, every time you set the period, please clear the counter by setting it to 0.

Let me know if this helps - I have not tested it but this comment is more from your description and a quick look at the main. So I hope thats the issue. otherwise will try it out in a kit

Regards,

Meenakshi Sundaram R

0 Likes