<?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>NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/44303/nrf24le1-how-to-set-pwm-frequency</link><description>To what values should I set the PWMCON register to so that the PWM0 and PWM1 frequency is output at 20Khz with duty cycle varying between 1 to 2ms. Now specifically I am asking this after reading the data sheet because the tables mentioned are not clearing</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 25 Apr 2019 12:35:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/44303/nrf24le1-how-to-set-pwm-frequency" /><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183818?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 12:35:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:805976c9-c27a-4461-912b-9839a1dbad1b</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;Yeah found that and corrected it...now it is working.. Thanks for your valuable support....&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183813?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 12:32:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0f8931f7-b8ce-4d11-9ea3-480f230d7045</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;You need to declare &amp;quot;timer_state&amp;quot; with a static uint8_t, instead of static bit. &amp;quot;bit&amp;quot; is a boolean type in 8051, and cannot be 2.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183797?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 12:14:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:630dd386-98e3-4124-bd55-8e7ffc02b79b</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;I wrote this code but it does not work,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void t0_interrupt(void) interrupt 1
{       
  // Timer increments every 2*12 CPU clock cycles
  // Timer starts counting down from 65535
  // 666 * 1,5 us = 999 us
  static bit timer_state;
  uint16_t timer_val;

	if(timer_state == 2)
  {
    // Need to adjust for the prior timer event
    timer_val = 0xFFFF - 13333 + 4*666;
		P03 = 0;
		P06 = 0;
    timer_state = 0;
  }
	
	if(timer_state == 1)
	{
		timer_val = 0xFFFF-666;
		P03 = 0;
		P06 = 1;
		timer_state = 2;
	}
  if (timer_state == 0)
  {
    timer_val = 0xFFFF - 666;
    P03 = 1;
		P06 = 0;
		timer_state = 1;
  }
  // Wait a given time, in this case 19 ms, before pulsing the pin again.
  
  TL0 = (uint8_t) (timer_val &amp;amp; 0xFF);
  TH0 = (uint8_t) ((timer_val &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I pulse one pin high for 1ms then I turn it low and pulse&amp;nbsp; second pin high and then update timer values to 20- 1-1-1-1. Since I am pulsing two pins and 2 ms for each pin.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183791?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 12:08:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e6f2ef6-8525-471c-af53-658550cc31f1</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;If (0xFFFF - 666) = 1 millisecond, 1.5 millisecond would be (0xFFFF - 1000).&lt;/p&gt;
&lt;p&gt;I think you need to sit down and fiddle a bit with your current timer function. You have all what you need in terms of calculations and how the timer works in general to be able to set/clear GPIOs at your wanted intervals.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183719?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 09:35:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:81cda0ff-eb56-4b45-860f-80a6f79b3f33</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;So if I have to pulse two pins, one for 1ms and the other for 1.5ms using the same timer then what could be the logic? Please give some guidance here..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183715?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 09:27:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f941210f-904a-44a8-91c8-8a232cf4a9ae</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;13333 = ~20ms, and 666 = ~1ms.&lt;/p&gt;
&lt;p&gt;You pulse the pin for 1 ms, which requires one interrupt to set the pin and one to clear the pin. This is in total 2 ms.&lt;/p&gt;
&lt;p&gt;To wait a total of 20 ms, you need to set a delay of 20 - 1 - 1 = 18 ms. For the timer itself, this translates to timer val = 13333 - 666 - 666.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183669?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 07:59:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3a41c860-0d8d-458b-8946-d2aa06bcbdee</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;Ok but I did not understand this statement. Why 13333 and why 2*666&lt;/p&gt;
&lt;p&gt;timer_val = 0xFFFF - 13333 + 2*666;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183656?ContentTypeID=1</link><pubDate>Thu, 25 Apr 2019 07:26:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7150a92d-e2fa-4a0d-b414-8a2ed295965b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;The &amp;quot;timer_state&amp;quot; toggles between creating a 1 ms pulse (if timer_state == false), and a 19 ms pulse (timer_state == true).&lt;/p&gt;
&lt;p&gt;As explained earlier, the timer peripheral starts counting down from 0xFFFF, with a frequency of 16M divided by 24 (equals to a period of 1.5 us per tick).&lt;/p&gt;
&lt;p&gt;You can then calculate the timer_val in each state.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183539?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 14:24:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e6c9dc26-034a-4140-99cb-0a08b56c2673</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;I did not understand this part of the code, especially the numbers and the calculations you are doing with them.&lt;/p&gt;
&lt;p&gt;if (timer_state == false)&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer_val = 0xFFFF - 666;&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (gpio_is_set == 1) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer_state = true;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; gpio_is_set ^=1;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; P10 ^= 1;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; // Wait a given time, in this case 19 ms, before pulsing the pin again.&lt;br /&gt;&amp;nbsp; else&lt;br /&gt;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // Need to adjust for the prior timer event&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer_val = 0xFFFF - 13333 + 2*666;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; timer_state = false;&lt;br /&gt;&amp;nbsp; }&lt;br /&gt;&amp;nbsp; TL0 = (uint8_t) (timer_val &amp;amp; 0xFF);&lt;br /&gt;&amp;nbsp; TH0 = (uint8_t) ((timer_val &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);&lt;br /&gt;}&lt;/p&gt;
&lt;p&gt;Could you please let me know how the logic is working here...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183310?ContentTypeID=1</link><pubDate>Wed, 24 Apr 2019 06:54:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ded7333-bc99-4d82-92df-7a62478acea6</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;I would recommend that you try a bit to see if you can fit this to your needs. Use a logic analyzer or a 2 ch oscilloscope to see if it pulses the way you want it to. Note that P02 should be writted with numbers, not letters (it seems like you have written it with an &amp;quot;O&amp;quot; instead of a &amp;quot;0&amp;quot;)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183197?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 15:16:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bc82285b-9840-4cd5-9ee7-c4e2514b0bba</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;Will this code do the trick&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void t0_interrupt(void) interrupt 1
{       
  // Timer increments every 2*12 CPU clock cycles
  // Timer starts counting down from 65535
	
  // 666 * 1,5 us = 999 us
  static bit timer_state1;
  static bit gpio_is_set1;
  uint16_t timer_val1;
	
	static bit timer_state1;
  static bit gpio_is_set1;
  uint16_t timer_val2;
  
  if (timer_state1 == 0)
  {
    timer_val1 = 0xFFFF - 666;
    
    if (gpio_is_set1 == 1) 
    {
        timer_state1 = 1;
    }
    gpio_is_set1 ^=1;
    P01 = 1;
  }
	// 666 * 1,5 us = 1500 us
	if(timer_state2 == 0)
	{
		timer_val1 = OxFFFF-666-999;
		if (gpio_is_set2 == 1) 
    {
        timer_state2 = 1;
    }
    gpio_is_set1 ^=1;
		PO2 = 1;
	}
  // Wait a given time, in this case 19 ms, before pulsing the pin again.
  else
  {
    // Need to adjust for the prior timer event
    timer_val1 = 0xFFFF - 13333 + 2*666;
		P01 = 0;
    timer_state1 = 0;
		
		timer_val1 = 0xFFFF - 13333 + 2*666 *2*999;
		P02 = 0;
    timer_state2 = 0;
  }
  TL0 = (uint8_t) (timer_val1 &amp;amp; 0xFF);
  TH0 = (uint8_t) ((timer_val1 &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/183182?ContentTypeID=1</link><pubDate>Tue, 23 Apr 2019 14:46:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ba594e52-6612-4feb-9752-68372e8afb14</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;If I have to control two servos with a single timer then how do I do that? Please let me know. I am trying to get a second servo working. Now the pulse width for both of the servos should be unique so that I can hold these servos at independent angles..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/175373?ContentTypeID=1</link><pubDate>Mon, 11 Mar 2019 14:11:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bec348c3-f521-4ad5-992c-9f547099101b</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to generate a 1 ms pulse then wait 20 ms, you can do something like this in your ISR routine:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void t0_interrupt(void) interrupt 1
{       
  // Timer increments every 2*12 CPU clock cycles
  // Timer starts counting down from 65535
  // 666 * 1,5 us = 999 us
  static bit timer_state;
  static bit gpio_is_set;
  uint16_t timer_val;
  
  if (timer_state == false)
  {
    timer_val = 0xFFFF - 666;
    
    if (gpio_is_set == 1) 
    {
        timer_state = true;
    }
    gpio_is_set ^=1;
    P10 ^= 1;
  }
  // Wait a given time, in this case 19 ms, before pulsing the pin again.
  else
  {
    // Need to adjust for the prior timer event
    timer_val = 0xFFFF - 13333 + 2*666;
    timer_state = false;
  }
  TL0 = (uint8_t) (timer_val &amp;amp; 0xFF);
  TH0 = (uint8_t) ((timer_val &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;You need to set the LED, wait x ms, then turn it off. Then you extend the timer to be 18 ms (20 ms total), then re-do the whole procedure.&lt;/p&gt;
&lt;p&gt;Could you try that?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/175178?ContentTypeID=1</link><pubDate>Sat, 09 Mar 2019 13:19:46 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6023da3c-ab01-4a8c-8b74-259a7ad57166</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;For the first section of the code I did this.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// Setupt a first compare match 
    //OCR1A = TCNT1 + US2TIMER1(100);
    short combined = (TH1 &amp;lt;&amp;lt; 8 )| TL1;
	  //CC1S = (CCH1 &amp;lt;&amp;lt; 8) | CCL2;
    short CC1S = combined + US2TIMER1(100); 
    // start timer 1 with no prescaler 
    //TCCR1B = (1 &amp;lt;&amp;lt; CS10);
		TR0 = 1;	
    // Enable interrupt 
    //TIMSK |= (1 &amp;lt;&amp;lt; OCIE1A);
		ET0 = 1;	&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is this right?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/175177?ContentTypeID=1</link><pubDate>Sat, 09 Mar 2019 12:47:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4fa2f2ec-1ee4-4b53-aef3-350b1dbb757b</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;I will try to modify my own AVR code for this and develop a library. I need you to tell the equivalent statements for the timers in NRF24LE1.&lt;/p&gt;
&lt;p&gt;1st section of code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void servoStart(void) 
{ 
    // Outputs 
	//if(servouniv&amp;lt;=7)
    SERVO_DDR |= SERVO_MASK; 
	//if(servouniv&amp;gt;7 &amp;amp;&amp;amp; servouniv&amp;lt;=15)
	SERVO_DDR1 |= SERVO_MASK;
    // Setupt a first compare match 
    OCR1A = TCNT1 + US2TIMER1(100); 
    // start timer 1 with no prescaler 
    TCCR1B = (1 &amp;lt;&amp;lt; CS10);       
    // Enable interrupt 
    TIMSK |= (1 &amp;lt;&amp;lt; OCIE1A); 
} 
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;2nd section of code&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ISR(TIMER1_COMPA_vect) 
{ 
    static uint16_t nextStart; 
    static int servo=-1; 
	static uint8_t servo1;
    static bool outputHigh = true; 
    uint16_t currentTime = OCR1A; 
    uint8_t mask = servoOutMask[servo]; 
//	uint8_t mask1 = servoOutMask1[servo]; 
    
	servouniv=servo;
	
    if (outputHigh)
	{ 

		if(servo&amp;gt;=6)
		SERVO_PORT1|= mask;
		if(servo&amp;lt;=5)
        SERVO_PORT |= mask; 
		
		
		//}
		/*if((servo&amp;gt;7)&amp;amp;&amp;amp;(servo&amp;lt;=15))
		{
		SERVO_PORT1 |= mask1;
		}*/
        // Set the end time for the servo pulse 
		
        OCR1A = currentTime + servoTime[servo]; 
		//if((servo&amp;gt;7)&amp;amp;&amp;amp;(servo&amp;lt;=15))
		//OCR1A = currentTime + servoTime[servo]; 
        nextStart = currentTime + US2TIMER1(SERVO_TIME_DIV); 
    } 
	
else
	{ 
		//.....// 
        OCR1A = nextStart; 
    } 
    outputHigh = !outputHigh; 
    }
    &lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please let me know the equivalent statements&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174974?ContentTypeID=1</link><pubDate>Fri, 08 Mar 2019 09:38:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d770c8f-f29b-45ea-a60c-967609fbf71c</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;Why do your waves always have 50% duty cycle? I am waiting for your reply. I posted more queries and some oscilloscope shots.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174869?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 15:58:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f5b5ec02-6467-4df9-a4be-147c7f35fd76</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/arduino-servo-signal.png" /&gt;&lt;/p&gt;
&lt;p&gt;The above signal is the arduino servo signal on which the servo works.&lt;/p&gt;
&lt;p&gt;The below signal is from the NRF24LE1 from the code you provided. It always appears that the duty cycle is 50%. How do I get it to 1 to 2ms Pulse width at 20 Hz frequency. Are you able to read the frequency of the the above signal?&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/nrf24le1-signal.png" /&gt;&lt;/p&gt;
&lt;p&gt;Give above is the NRF24LE1 PWM signal and it appears that the duty cycle is always 50%. Why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174730?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 08:17:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:79ad49f3-3c47-41b4-836d-c9befea0fa42</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;So for 50 Hz you took 10000us so for 20Hz it would be 25000us. Therefore X will be 25000/1.5 = 16,666. But now how do I get a PWM or 1 to 2milli second pulse width here in 20Hz wave? Please let me know. Again the pulse width of 1ms to 2ms calculation at 20Hz is not clear to me. Please let me know the exact numbers..&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174725?ContentTypeID=1</link><pubDate>Thu, 07 Mar 2019 08:07:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:954d5375-64b1-4aeb-988b-c9918eacf141</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Each tick is CPU_CLOCK / 12*2 = 1,5 us per tick. Timer starts decrementing from 0xFFFF and down.&lt;/p&gt;
&lt;p&gt;That gives (for 50 Hz):&lt;/p&gt;
&lt;p&gt;10000 us = x * 1,5, x = 10000/1,5.&lt;/p&gt;
&lt;p&gt;timer_val = 0xFFFF - 6666.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;If you want 20 Hz, you need to adjust the above value to match 1/ 2*(20 Hz), as you want to toggle the GPIO two times to generate the signal.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174644?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 17:23:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64a955da-3dbb-4aeb-ae7a-faf0d83ed66b</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;Yes, I scoped the pin and was able to see the PWM signal. I was also able to adjust to pulse width. But how do I change the frequency of the wave? Like if I want to change from 50Hz to 20Hz what parts of the code do I need to change? Which numbers do I need to change? What I found that the arduino is putting out a PWM signal at much less frequency like around 20Hz. Now how do I change the PWM generated by your code from 50Hz to 20Hz. Please explain the calculation.&lt;/p&gt;
&lt;p&gt;How are you arriving at these numbers (as mentioned in your code)?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;// Timer increments every 2*12 CPU clock cycles&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;&amp;nbsp; // Timer starts counting down from 65535&lt;br /&gt;&amp;nbsp; // 6666 * 1,5 us = 9999 us&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174558?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 13:07:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:58beddff-af37-40fc-8b6e-5ab9d2575fed</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did you scope the correct pin? P1.0 should toggle in the example I posted.&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s the logic analyzer trace:&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-212d8306d25f40c09927dfe10daa1bd4/pastedimage1551877614695v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174531?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 12:20:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:56a508af-e8ce-4244-a7d7-22b18fc13469</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;The code you provided above does not work. I found this. Will this code work? (It seemed to work some times).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;reg24le1.h&amp;quot; // I/O header file for NRF24LE1
#include &amp;quot;hal_delay.h&amp;quot; // header file containing delay functions




#include &amp;quot;reg24le1.h&amp;quot; // I/O header file for NRF24LE1
#include &amp;lt;stdlib.h&amp;gt; // standard library
#include &amp;lt;string.h&amp;gt; // library containing string functions
#include &amp;lt;stdio.h&amp;gt; // standard I/O library
#include &amp;quot;hal_clk.h&amp;quot;
//#include &amp;lt;reg51.h&amp;gt;
#include &amp;quot;hal_rtc.h&amp;quot;
// PWM_Pin
sbit PWM_Pin = P0^6;		   // Pin P2.0 is named as PWM_Pin

// Function declarations
void cct_init(void);
void InitTimer0(void);
void InitPWM(void);

// Global variables
unsigned char PWM = 0;	  // It can have a value from 0 (0% duty cycle) to 255 (100% duty cycle)
unsigned int temp = 0;    // Used inside Timer0 ISR

// PWM frequency selector
/* PWM_Freq_Num can have values in between 1 to 257	only
 * When PWM_Freq_Num is equal to 1, then it means highest PWM frequency
 * which is approximately 1000000/(1*255) = 3.9kHz
 * When PWM_Freq_Num is equal to 257, then it means lowest PWM frequency
 * which is approximately 1000000/(257*255) = 15Hz
 *
 * So, in general you can calculate PWM frequency by using the formula
 *     PWM Frequency = 1000000/(PWM_Freq_Num*255)
 */
/*#define PWM_Freq_Num   78	 // Highest possible PWM Frequency


void mcu_init(void)
{  
	hal_clk_set_freq(HAL_CLK_1MHZ);// = 4
  hal_clklf_set_source(HAL_CLKLF_XOSC16M_SYNTH);    // Synthesize 32 KHz from 16 MHz clock  
	//hal_clklf_set_source(HAL_CLKLF_RCOSC32K);
	hal_clk_set_freq(HAL_CLK_1MHZ);
  hal_rtc_set_compare_mode(HAL_RTC_COMPARE_MODE_0); // Use 32 KHz timer mode 0
  //hal_clk_regret_xosc16m_on(true);                  // Keep XOSC16M on in register retention
  //while (hal_clk_get_16m_source() != HAL_CLK_XOSC16M) {}
}

// Main Function
int main(void)
{
	 hal_clk_set_freq(HAL_CLK_1MHZ);
   cct_init();   	       // Make all ports zero
   InitPWM();              // Start PWM
 
   PWM = 0;              // Make 50% duty cycle of PWM

   while(1)                // Rest is done in Timer0 interrupt
   {
	 delay_ms(1);
		 PWM++;
		 if(PWM&amp;gt;=254)
			 PWM=0;
	 }
}

// Init CCT function
void cct_init(void)
{
	P0 = 0x00;   
	P1 = 0x00;   
	P2 = 0x00;   
	P3 = 0x00;  
}

// Timer0 initialize
void InitTimer0(void)
{
	TMOD &amp;amp;= 0xF0;    // Clear 4bit field for timer0
	TMOD |= 0x01;    // Set timer0 in mode 1 = 16bit mode
	
	TH0 = 0x00;      // First time value
	TL0 = 0x00;      // Set arbitrarily zero
	
	ET0 = 1;         // Enable Timer0 interrupts
	EA  = 1;         // Global interrupt enable
	
	TR0 = 1;         // Start Timer 0
}

// PWM initialize
void InitPWM(void)
{
	PWM = 0;         // Initialize with 0% duty cycle
	InitTimer0();    // Initialize timer0 to start generating interrupts
					 // PWM generation code is written inside the Timer0 ISR
}

// Timer0 ISR
void Timer0_ISR (void) interrupt 1   
{
	TR0 = 0;    // Stop Timer 0

	if(PWM_Pin)	// if PWM_Pin is high
	{
		PWM_Pin = 0;
		temp = (255-PWM)*PWM_Freq_Num;
		TH0  = 0xFF - (temp&amp;gt;&amp;gt;8)&amp;amp;0xFF;
		TL0  = 0xFF - temp&amp;amp;0xFF;	
	}
	else	     // if PWM_Pin is low
	{
		PWM_Pin = 1;
		temp = PWM*PWM_Freq_Num;
		TH0  = 0xFF - (temp&amp;gt;&amp;gt;8)&amp;amp;0xFF;
		TL0  = 0xFF - temp&amp;amp;0xFF;
	}

	TF0 = 0;     // Clear the interrupt flag
	TR0 = 1;     // Start Timer 0
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Could you tell me what is wrong with my code and the code you gave me?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174467?ContentTypeID=1</link><pubDate>Wed, 06 Mar 2019 08:39:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d5672b4-36d9-4d0a-89b8-b1239ee38cac</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Could you try this instead?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;nrf24le1.h&amp;quot;

void timer0_init(void)
{
  TMOD |= 0x01; //16 bit timer
  TR0 = 1; //start timer
  ET0=1; //enable interrupt

}


void t0_interrupt(void) interrupt 1
{       
  // Timer increments every 2*12 CPU clock cycles    
  // Timer starts counting down from 65535
  // 6666 * 1,5 us = 9999 us
  uint16_t timer_val = 0xFFFF - 6666;
  P10 ^= 1;
  TL0 = (uint8_t) (timer_val &amp;amp; 0xFF);
  TH0 = (uint8_t) ((timer_val &amp;gt;&amp;gt; 8) &amp;amp; 0xFF);
}

void main(void)
{
    // Configure TXD pin as output.
    // P0.5, P0.3 and P1.0 are configured as outputs to make the example run on
    // either 24-pin, 32-pin or 48-pin nRF24LE1 variants.
    P0DIR = 0x00;
    P1DIR = 0x00;  

    CLKCTRL |=  0x1;
    // Enable global interrupts
    EA = 1;
    timer0_init();
    for(;;)
    {    
     
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This should generate a 50 hz pulse.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174361?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 16:44:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1026b13c-c893-4793-9f84-d46a88150a40</guid><dc:creator>infibit</dc:creator><description>&lt;p&gt;Here is a 15ms timer delay pulse. How do I change it to get a 20ms delay pulse and thus a 50Hz pulse?&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;quot;reg24le1.h&amp;quot; // I/O header file for NRF24LE1
#include &amp;lt;stdlib.h&amp;gt; // standard library
#include &amp;lt;string.h&amp;gt; // library containing string functions
#include &amp;lt;stdio.h&amp;gt; // standard I/O library
 
sfr16 DPTR = 0X82; // declare functional register DPTR
 
// main function
void main()
{
 
int i = 0;
P1DIR = 0; // Port1 as output
 
P10 = 0; // Pin 0 of Port 1 low
 
EA = 1; // Enable global interrupt
TMOD = 0X01 ; // timer0 in 16bit mode1
TR0 = 1; // start timer
 
// infinite loop
while(1)
{
TH0 = 0; // initialise timer register upper byte
TL0 = 0; // initialise timer register lower byte
while(TF0 == 0); // wait for timer overflow flag
TF0 = 0; // clear flag
P10 =1; // make Pin0 of Port1 high
TH0 = 0; // initialise timer register upper byte
TL0 = 0; // initialise timer register lower byte
while(TF0 == 0); // wait for timer overflow flag
TF0 = 0; // clear flag
P10 = 0; // make Pin0 of Port1 low
}
}

 &lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF24LE1 how to set PWM frequency?</title><link>https://devzone.nordicsemi.com/thread/174194?ContentTypeID=1</link><pubDate>Tue, 05 Mar 2019 09:35:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2460baa2-fb9d-44f6-b849-07df1a74c382</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;We do not have a softPWM library available for the nRF24L-series devices. You&amp;#39;ll have to manually use the timer to generate the pulse.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>