<?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>Simple PWM example</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/109864/simple-pwm-example</link><description>Hi, 
 Is it possible to have a simple example of using PWM with the Zephyr? 
 With nRF5_SDK_17.1.0 I did this: 
 
 I used the Pwm1SetDutyCycle function to set the Duty cycle of the 4 channels. Now what do I do with the Zephyr? Can anyone give me an example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Apr 2024 13:04:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/109864/simple-pwm-example" /><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/479231?ContentTypeID=1</link><pubDate>Wed, 17 Apr 2024 13:04:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f07259a7-2c90-4c65-b81c-9911d13328ca</guid><dc:creator>Stefano1984</dc:creator><description>&lt;p&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Thank you very much Andreas.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;I think I will raise a new case.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/478973?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 12:04:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7ea6163a-97f6-44bc-bc7c-f429664f742c</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately I do not have a solution for the I2C issues you&amp;#39;re observing unless it is explained by the lesson I posted in my previous reply. If you want you could raise a new case for that since it is a different topic than the generic PWM topic of this cases original question, but I will look into your this topic during this week if you want to wait a bit for a reply.&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/478894?ContentTypeID=1</link><pubDate>Tue, 16 Apr 2024 08:29:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae3039ad-1588-4def-93c3-ed82c0377e8f</guid><dc:creator>Stefano1984</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;Andreas,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;do you have a solution to my problem?&lt;br /&gt;Thank you&lt;br /&gt;Best regards&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/478826?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2024 15:21:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:07a8d86c-cbcc-43b1-8cd2-09a2c96ae831</guid><dc:creator>rajeev</dc:creator><description>&lt;p&gt;hmm then this is concerning.&amp;nbsp; Lemme try on my end and see what works. Else. hopefully Nordic tech team can suggest a solution.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/478676?ContentTypeID=1</link><pubDate>Mon, 15 Apr 2024 08:38:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b78ce0b8-80f0-44f8-b2c6-137693b81ed4</guid><dc:creator>Stefano1984</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Thanks for the reply but it still gives me the same error:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define I2C_BITRATE_10KHZ 10000
#define I2C_BITRATE_STANDARD	100000	/* 100 Kbit/s */
#define I2C_BITRATE_FAST	400000	/* 400 Kbit/s */
#define I2C_BITRATE_FAST_PLUS	1000000 /* 1 Mbit/s */
#define I2C_BITRATE_HIGH	3400000	/* 3.4 Mbit/s */
#define I2C_BITRATE_ULTRA	5000000 /* 5 Mbit/s */&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c0 {
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;;
	clock-frequency = &amp;lt;I2C_BITRATE_10KHZ&amp;gt;;
};&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;static assertion failed: &amp;quot;Wrong I2C 0 frequency setting in dts&amp;quot;&lt;/p&gt;
&lt;p&gt;Do you have any other suggestions?&lt;br /&gt;Thank you.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/478592?ContentTypeID=1</link><pubDate>Fri, 12 Apr 2024 16:36:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:db65d14c-e1ea-4cf1-88f2-9afd9d4f6b48</guid><dc:creator>rajeev</dc:creator><description>&lt;p&gt;Maybe try setting in&amp;nbsp;&lt;span&gt;i2c.h&amp;nbsp;the following&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;&lt;code&gt;#define I2C_BITRATE_10KHZ&amp;nbsp;10000 //your custom freq value&lt;/code&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Then set&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;br /&gt;&lt;code&gt;&amp;amp;i2c0 {&lt;/code&gt;&lt;br /&gt;&lt;code&gt; status = &amp;quot;okay&amp;quot;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; pinctrl-names = &amp;quot;default&amp;quot;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt; clock-frequency = &amp;lt;I2C_BITRATE_10KHZ&amp;gt;;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;};&lt;/code&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;See if that helps incase the device tree and&amp;nbsp; I2C driver is only able to set frequency values defined in the&amp;nbsp;i2c.h which zephyr looks for.&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: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/478251?ContentTypeID=1</link><pubDate>Thu, 11 Apr 2024 09:54:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05e77498-f9f8-4496-9c46-bfd34b4e8abd</guid><dc:creator>Stefano1984</dc:creator><description>&lt;p&gt;HI,&lt;br /&gt;I didn&amp;#39;t understand how this solves my problem.&lt;br /&gt;I2C_BITRATE_FAST corresponds to a frequency of 400 Kbit/s as specified in the i2c.h file:&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define I2C_BITRATE_STANDARD	100000	/* 100 Kbit/s */
#define I2C_BITRATE_FAST	400000	/* 400 Kbit/s */        &amp;lt;--------
#define I2C_BITRATE_FAST_PLUS	1000000 /* 1 Mbit/s */
#define I2C_BITRATE_HIGH	3400000	/* 3.4 Mbit/s */
#define I2C_BITRATE_ULTRA	5000000 /* 5 Mbit/s */&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I need to go at a slower speed. I need a speed of 10 Kbit/s.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;With nRF SDK I was able to do this by setting &amp;quot;frequency = 0x00290000UL&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void ext_twi_init(void)
{
    ret_code_t err_code;

    const nrf_drv_twi_config_t twi_config = {
       .scl                = EXT_SCL_PIN,
       .sda                = EXT_SDA_PIN,
       .frequency          = 0x00290000UL,      // = 10Kbit/s. &amp;lt;------------
       .interrupt_priority = APP_IRQ_PRIORITY_HIGH,
       .clear_bus_init     = false
    };

    err_code = nrf_drv_twi_init(&amp;amp;m_ext_twi, &amp;amp;twi_config, NULL, NULL);
    APP_ERROR_CHECK(err_code);

    nrf_drv_twi_enable(&amp;amp;m_ext_twi);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;How do I do the same thing using Zephyr?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Thank you&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/477246?ContentTypeID=1</link><pubDate>Fri, 05 Apr 2024 08:02:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa405f0c-d697-4256-a3ff-1b981eef8c09</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;TWI/I2C should be covered in lesson 6 in&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-fundamentals/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/477212?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2024 21:09:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95a64f14-b214-4dab-885d-42b09de29f5a</guid><dc:creator>rajeev</dc:creator><description>&lt;p&gt;The i2c clock freq in zephyr needs to be set as such:&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;I2C_BITRATE_FAST etc....&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;&amp;amp;i2c1 {
	compatible = &amp;quot;nordic,nrf-twim&amp;quot;;
	status = &amp;quot;okay&amp;quot;;
	clock-frequency = &amp;lt;I2C_BITRATE_FAST&amp;gt;;

	pinctrl-0 = &amp;lt;&amp;amp;i2c1_default&amp;gt;;
	pinctrl-1 = &amp;lt;&amp;amp;i2c1_sleep&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;, &amp;quot;sleep&amp;quot;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;See all those frequency settings here&lt;br /&gt;&lt;a id="" href="https://docs.zephyrproject.org/apidoc/latest/dt-bindings_2i2c_2i2c_8h.html"&gt;https://docs.zephyrproject.org/apidoc/latest/dt-bindings_2i2c_2i2c_8h.html&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/477184?ContentTypeID=1</link><pubDate>Thu, 04 Apr 2024 16:05:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10985ef1-7fb9-44f0-9350-abc46d1e36d5</guid><dc:creator>Stefano1984</dc:creator><description>&lt;p&gt;Thank you,&lt;br /&gt;these lessons are very useful.&lt;br /&gt;However, I notice that there is a lesson missing that deals with the TWI module.&lt;br /&gt;I was still able to communicate via the I2C BUS but I can&amp;#39;t set the clock frequency. In particular I want to set a frequency of 10 kHz but I don&amp;#39;t know how.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I tried to do like this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;&amp;amp;i2c0 {
	status = &amp;quot;okay&amp;quot;;
	pinctrl-0 = &amp;lt;&amp;amp;i2c0_default&amp;gt;;
	pinctrl-names = &amp;quot;default&amp;quot;;
	clock-frequency = &amp;lt;10000&amp;gt;;
};&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But it gives me the following error:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;C:/ncs/v2.6.0-rc2/zephyr/include/zephyr/toolchain/gcc.h:87:36: error: static assertion failed: &amp;quot;Wrong I2C 0 frequency setting in dts&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Can you help me?&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span class="jCAhz ChMk0b"&gt;&lt;span class="ryNqvb"&gt;Thank you&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Simple PWM example</title><link>https://devzone.nordicsemi.com/thread/476857?ContentTypeID=1</link><pubDate>Wed, 03 Apr 2024 11:48:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:910b0802-21b4-4cd4-9e5d-86c5f0f7e921</guid><dc:creator>AHaug</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In lesson 4 in&amp;nbsp;&lt;a href="https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/"&gt;https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/&lt;/a&gt;&amp;nbsp;we have a course showcasing how to use the PWM API in Zephyr through nRF Connect SDK. I recommend that you have a look at this. The solution to the hands on in this lesson can be seen in&amp;nbsp;&lt;a href="https://github.com/NordicDeveloperAcademy/ncs-inter/tree/main/lesson4."&gt;github.com/.../lesson4.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;br /&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>