<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>PWM driving a Buzzer</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/54501/pwm-driving-a-buzzer</link><description>I am using SDK V15 with an nRF52DK and Keil compiler. 
 I have difficulty finding an example to use a GPIO to drive a Piezo Buzzer. The requirement is very simple: use a GPIO to generate a sound frequency of about 18 Khz to the Buzzer. 
 The PWM examples</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 27 Nov 2019 19:15:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/54501/pwm-driving-a-buzzer" /><item><title>RE: PWM driving a Buzzer</title><link>https://devzone.nordicsemi.com/thread/222455?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2019 19:15:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b4ca1dd5-4b4d-4cc9-bd9c-1c8eb31127d3</guid><dc:creator>vn2000</dc:creator><description>&lt;p&gt;Since I was running the buzzer at 10Khz, I can see the signal with the duty cycle varying during the buzz. After it is complete, I can still see the same 10Khz signal but with a fixed duty cycle at around. 10%.&lt;/p&gt;
&lt;p&gt;Anyway I used the app_pwm_disable() and it goes back to be quiet.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The issue is resolved. Thank you for your help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM driving a Buzzer</title><link>https://devzone.nordicsemi.com/thread/222251?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2019 09:01:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41898bb5-1232-4236-a0a5-4c19903b052c</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;What does the pulses look like, and how did you stop it?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Either try to set the duty cycle to 0% or 100%, depending on whether you want it high or low (it is also dependent on what your active state on the PWM channel is set to, high or low).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can you show me what it looks like? Alternatively, you can disable the PWM instance using app_pwm_disable().&amp;nbsp;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM driving a Buzzer</title><link>https://devzone.nordicsemi.com/thread/222212?ContentTypeID=1</link><pubDate>Wed, 27 Nov 2019 05:50:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cee72113-36f9-42ed-a4b0-e981bc3b7248</guid><dc:creator>vn2000</dc:creator><description>&lt;p&gt;Hi Edwin,&lt;/p&gt;
&lt;p&gt;Last week I was busy working on the PCB. Now I got back and was able to use examples from the app_pwm module thanks to your suggestion.&lt;/p&gt;
&lt;p&gt;However I have one more question: After I drive the buzzer for a few seconds then stop. But even after it stopped I can still see pulses coming out from that GPIO, using an oscilloscope. What do I need to do to let that GPIO completely quiet (either high or low). Do I need to reconfigure that GPIO?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM driving a Buzzer</title><link>https://devzone.nordicsemi.com/thread/221089?ContentTypeID=1</link><pubDate>Wed, 20 Nov 2019 13:22:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7a0b688-cef8-46f7-aaa4-d7f3de0bbdf6</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;The app_pwm module, which is used in the pwm_library example doesn&amp;#39;t use the PWM peripheral, but the TIMER and GPIOTE to toggle the pins. Hence, the PWM_PRESCALER is not used in this project.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Have you tried to analyze the PWM output to see that it has the PWM period and PWM duty cycle that you expect?&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM driving a Buzzer</title><link>https://devzone.nordicsemi.com/thread/220708?ContentTypeID=1</link><pubDate>Tue, 19 Nov 2019 05:32:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:029481d3-870c-4302-b94a-3e6ae74617d9</guid><dc:creator>vn2000</dc:creator><description>&lt;p&gt;I was using the pwm_library and manage to have the demo2 barely working,&lt;/p&gt;
&lt;p&gt;The buzzer barely makes a sound but not at the frequency at 18 Khz as I wish.&lt;/p&gt;
&lt;p&gt;I looked at the value of the pre-scaler of PWM_CLK in nrf52_bitfields.h and they are not as flexible. The values keep being divided by 2 as follows:&lt;/p&gt;
&lt;p&gt;#define PWM_PRESCALER_PRESCALER_DIV_1 (0UL) /*!&amp;lt; Divide by 1 (16MHz) */&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_2 (1UL) /*!&amp;lt; Divide by 2 ( 8MHz) */&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_4 (2UL) /*!&amp;lt; Divide by 4 ( 4MHz) */&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_8 (3UL) /*!&amp;lt; Divide by 8 ( 2MHz) */&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_16 (4UL) /*!&amp;lt; Divide by 16 ( 1MHz) */&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_32 (5UL) /*!&amp;lt; Divide by 32 ( 500kHz) */&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_64 (6UL) /*!&amp;lt; Divide by 64 ( 250kHz) */&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_128 (7UL) /*!&amp;lt; Divide by 128 ( 125kHz) */&lt;/p&gt;
&lt;p&gt;I tried to add more prescalers:&lt;/p&gt;
&lt;p&gt;#define PWM_PRESCALER_PRESCALER_DIV_256 (8UL) /*!&amp;lt; Divide by 256 ( 62.5kHz) barely working*/&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_512 (9UL) /*!&amp;lt; Divide by 512 ( 31.25kHz) not working*/&lt;br /&gt;#define PWM_PRESCALER_PRESCALER_DIV_1024 (10UL) /*!&amp;lt; Divide by 1024 ( 15.625kHz) not working*/&lt;/p&gt;
&lt;p&gt;Of the above, only&amp;nbsp;&lt;span&gt;PWM_PRESCALER_PRESCALER_DIV_256 is barely working.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;And 62.5 Khz is not even in the audio frequency.range.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is there a way to readjust the above definitions in a more flexible way to get the audio frequency at 18 Khz?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: PWM driving a Buzzer</title><link>https://devzone.nordicsemi.com/thread/220618?ContentTypeID=1</link><pubDate>Mon, 18 Nov 2019 14:23:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d0c623fb-f3ca-4f36-bce8-f518f70ad253</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I suggest you take a look at the pwm_library example instead of the pwm_driver. It is a bit easier, and more suited to generate a steady PWM signal. The pwm_driver example is intended for automatic manipulation of the PMW duty cycles, if you want to e.g. play a short sound clip, or do a LED blink pattern.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>