<?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>NRF52 help configuring TIMER + DMA + PWM</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28686/nrf52-help-configuring-timer-dma-pwm</link><description>I need help configuring TIMER + DMA + PWM ( nrf52 ). 
 I would like to set the value of PWM with an interval of 100 ms and PWM configured to frequency of 20-40kHz. 
 Optinal use of EasyDMA for the PWM module is redundant over the resources used and</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Dec 2017 11:35:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28686/nrf52-help-configuring-timer-dma-pwm" /><item><title>RE: NRF52 help configuring TIMER + DMA + PWM</title><link>https://devzone.nordicsemi.com/thread/113707?ContentTypeID=1</link><pubDate>Thu, 28 Dec 2017 11:35:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a1a5b5eb-0cbc-4648-afcc-42d93c4b4935</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What have you set the PRESCALER and COUNTERTOP values to, when switching to 50kHz?&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 help configuring TIMER + DMA + PWM</title><link>https://devzone.nordicsemi.com/thread/113705?ContentTypeID=1</link><pubDate>Fri, 22 Dec 2017 16:52:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7786ac39-0b99-4ddf-82f6-d44c4bf53603</guid><dc:creator>zachtos</dc:creator><description>&lt;p&gt;hello,    the code in the example works on the PWM frequency 25KHz
but nrf5d dk can not start correctly at 50 kHz&lt;/p&gt;
&lt;p&gt;pwm is integrated into the working project. I&amp;#39;ll make an example later&lt;/p&gt;
&lt;p&gt;examples from the library are designed for a small frequency of 1 kHz&lt;/p&gt;
&lt;p&gt;if you have an example at 50 kHz
or hex for nrf52 DK with implemented PWM.
happy to check on nrf52 DK&lt;/p&gt;
&lt;p&gt;In any way it is impossible to generate a correct signal.
what are the peaks is the way out but it&amp;#39;s wrong.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/question/69566/nrf52-clock-in-and-out/"&gt;devzone.nordicsemi.com/.../&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;this example generates only 222 kHz perhaps this will tell where the problem. is compiled on nrf52 dk keil, my project sdk_config.h&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 help configuring TIMER + DMA + PWM</title><link>https://devzone.nordicsemi.com/thread/113708?ContentTypeID=1</link><pubDate>Fri, 22 Dec 2017 10:23:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8e708dfb-3584-4db8-ab11-0f3b87315f61</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;What is the cfg_IR_Transmit.Carrier_period_pwm variable set to, and what values do you put into the PWM buffer?&lt;/p&gt;
&lt;p&gt;It might be easier if you can just zip your project and attach it as a file. Then I can more easily compile and test your code.&lt;/p&gt;
&lt;p&gt;Best regards&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 help configuring TIMER + DMA + PWM</title><link>https://devzone.nordicsemi.com/thread/113706?ContentTypeID=1</link><pubDate>Thu, 21 Dec 2017 16:20:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2f3f5014-3e39-4a75-ac1a-4ba2d2d86a51</guid><dc:creator>zachtos</dc:creator><description>&lt;p&gt;Yes, we are inexperienced with using PPI for NRF52.&lt;/p&gt;
&lt;p&gt;The problem seems to be deeper, PWM configured to 50kHz produces such a strange signal that you could doubt the controller&amp;#39;s settings the PWM does not work above 25kHz, any duty not equal to 50% at 25kHz gives the wrong and strange pwm signal.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#define LLOW  0 
#define LHIGH 1 
#define TIMER_RELOAD     		8000   
#define TIMER_RELOAD_CC_NUM  	5
#define PWM0_PPI_CH_A       	0

void PWM0_IRQHandler ( void )   // not init now 
{
if ( NRF_PWM0-&amp;gt;EVENTS_PWMPERIODEND )
{
    NRF_PWM0-&amp;gt;EVENTS_PWMPERIODEND = 0;
	nrf_gpio_pin_write	( 17, LLOW );
}
}

//!   __O  uint32_t  TASKS_STOP;                        &amp;lt; Stops PWM pulse generation on all channels at the end of current
//!                                                       PWM period, and stops sequence playback                               
//!   __O  uint32_t  TASKS_SEQSTART[2];                 &amp;lt; Description collection[0]: Loads the first PWM value on all
//!                                                       enabled channels from sequence 0, and starts playing that sequence
//!                                                        at the rate defined in SEQ[0]REFRESH and/or DECODER.MODE. Causes
//!                                                        PWM generation to start it was not running.                          
//!   __O  uint32_t  TASKS_NEXTSTEP;                    &amp;lt; Steps by one value in the current sequence on all enabled channels
//!                                                       if DECODER.MODE=NextStep. Does not cause PWM generation to start
//!                                                        it was not running.                                                  
//!   __IO uint32_t  EVENTS_STOPPED;                    &amp;lt; Response to STOP task, emitted when PWM pulses are no longer
//!                                                       generated                                                             
//!   __IO uint32_t  EVENTS_SEQSTARTED[2];              &amp;lt; Description collection[0]: First PWM period started on sequence
//!                                                       0                                                                     
//!   __IO uint32_t  EVENTS_SEQEND[2];                  &amp;lt; Description collection[0]: Emitted at end of every sequence
//!                                                       0, when last value from RAM has been applied to wave counter          
//!   __IO uint32_t  EVENTS_PWMPERIODEND;               &amp;lt; Emitted at the end of each PWM period                                 
//!   __IO uint32_t  EVENTS_LOOPSDONE;                  &amp;lt; Concatenated sequences have been played the amount of times
//!                                                       defined in LOOP.CNT                                                   
//!   __IO uint32_t  SHORTS;                            &amp;lt; Shortcut register                                                     
//!   __IO uint32_t  INTEN;                             &amp;lt; Enable or disable interrupt                                           
//!   __IO uint32_t  INTENSET;                          &amp;lt; Enable interrupt                                                      
//!   __IO uint32_t  INTENCLR;                          &amp;lt; Disable interrupt                                                     
//!   __IO uint32_t  ENABLE;                            &amp;lt; PWM module enable register                                            
//!   __IO uint32_t  MODE;                              &amp;lt; Selects operating mode of the wave counter                            
//!   __IO uint32_t  COUNTERTOP;                        &amp;lt; Value up to which the pulse generator counter counts                  
//!   __IO uint32_t  PRESCALER;                         &amp;lt; Configuration for PWM_CLK                                             
//!   __IO uint32_t  DECODER;                           &amp;lt; Configuration of the decoder                                          
//!   __IO uint32_t  LOOP;                              &amp;lt; Amount of playback of a loop                                          
//!	PWM_SEQ_Type;
//! __IO uint32_t  SEQx.PTR;                               /*!&amp;lt; Description cluster[0]: Beginning address in Data RAM of this
//!                                                       sequence                                                              */
//!__IO uint32_t  SEQx.CNT;                               /*!&amp;lt; Description cluster[0]: Amount of values (duty cycles) in this
//!                                                       sequence                                                              */
//!__IO uint32_t  SEQx.REFRESH;                           /*!&amp;lt; Description cluster[0]: Amount of additional PWM periods between
//!                                                       samples loaded into compare register                                  */
//!__IO uint32_t  SEQx.ENDDELAY;                          /*!&amp;lt; Description cluster[0]: Time added after the sequence                 */

void config_pwm_hardware (  void )
{

	nrf_gpio_cfg_output ( PIN_TST_PWM ); 
	nrf_gpio_pin_write	( PIN_TST_PWM, LLOW );

    nrf_gpio_cfg_output ( 17 ); 
	nrf_gpio_pin_write	( 17, LHIGH );

//  GPIO clock ?
// 	

// init timer3,  clock source  next step
// 24-bit, base frequency 16 MHz, auto clear on COMPARE5 match (CC5 = TIMER_RELOAD)
 NRF_TIMER3-&amp;gt;BITMODE                 = TIMER_BITMODE_BITMODE_24Bit &amp;lt;&amp;lt; TIMER_BITMODE_BITMODE_Pos;
 NRF_TIMER3-&amp;gt;PRESCALER               = 0;
 NRF_TIMER3-&amp;gt;SHORTS                  = TIMER_SHORTS_COMPARE0_CLEAR_Msk &amp;lt;&amp;lt; TIMER_RELOAD_CC_NUM;
 NRF_TIMER3-&amp;gt;MODE                    = TIMER_MODE_MODE_Timer &amp;lt;&amp;lt; TIMER_MODE_MODE_Pos;
 NRF_TIMER3-&amp;gt;CC[TIMER_RELOAD_CC_NUM] = TIMER_RELOAD;    

 NRF_PWM0-&amp;gt;PSEL.OUT[0] =   (PIN_TST_PWM &amp;lt;&amp;lt; PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Connected &amp;lt;&amp;lt; PWM_PSEL_OUT_CONNECT_Pos);
 NRF_PWM0-&amp;gt;PSEL.OUT[1] =   (0 &amp;lt;&amp;lt; PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Disconnected &amp;lt;&amp;lt; PWM_PSEL_OUT_CONNECT_Pos);
 NRF_PWM0-&amp;gt;PSEL.OUT[2] =   (1 &amp;lt;&amp;lt; PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Disconnected &amp;lt;&amp;lt; PWM_PSEL_OUT_CONNECT_Pos);
 NRF_PWM0-&amp;gt;PSEL.OUT[3] =   (2 &amp;lt;&amp;lt; PWM_PSEL_OUT_PIN_Pos) | (PWM_PSEL_OUT_CONNECT_Disconnected &amp;lt;&amp;lt; PWM_PSEL_OUT_CONNECT_Pos);
    
 NRF_PWM0-&amp;gt;ENABLE 		= (PWM_ENABLE_ENABLE_Enabled &amp;lt;&amp;lt; PWM_ENABLE_ENABLE_Pos);
 NRF_PWM0-&amp;gt;MODE 		= (PWM_MODE_UPDOWN_Up 			&amp;lt;&amp;lt; PWM_MODE_UPDOWN_Pos);
 NRF_PWM0-&amp;gt;PRESCALER 	= (PWM_PRESCALER_PRESCALER_DIV_1 &amp;lt;&amp;lt; PWM_PRESCALER_PRESCALER_Pos);
 NRF_PWM0-&amp;gt;COUNTERTOP 	= ( cfg_IR_Transmit.Carrier_period_pwm &amp;lt;&amp;lt; PWM_COUNTERTOP_COUNTERTOP_Pos);
 NRF_PWM0-&amp;gt;DECODER 		= (PWM_DECODER_LOAD_Common &amp;lt;&amp;lt; PWM_DECODER_LOAD_Pos)|(PWM_DECODER_MODE_NextStep &amp;lt;&amp;lt; PWM_DECODER_MODE_Pos);
 NRF_PWM0-&amp;gt;SEQ[0].PTR 	= ((uint32_t)(ARRAY_PWM_DATA) &amp;lt;&amp;lt; PWM_SEQ_PTR_PTR_Pos);
 NRF_PWM0-&amp;gt;SEQ[0].CNT 	= 0; // ( length_data &amp;lt;&amp;lt; PWM_SEQ_CNT_CNT_Pos); 

 NRF_PWM0-&amp;gt;SEQ[0].REFRESH 	= 0; 
 NRF_PWM0-&amp;gt;SEQ[0].ENDDELAY  = 0; 
 NRF_PWM0-&amp;gt;SEQ[1].PTR 		= 0;  
 NRF_PWM0-&amp;gt;SEQ[1].CNT 		= 0;  
 NRF_PWM0-&amp;gt;SEQ[1].REFRESH 	= 0;  
 NRF_PWM0-&amp;gt;SEQ[1].ENDDELAY 	= 0;  
 NRF_PWM0-&amp;gt;SHORTS 			= 0;  
 NRF_PWM0-&amp;gt;LOOP 			= 0;  
 NRF_PWM0-&amp;gt;TASKS_NEXTSTEP   = 1;  
 NRF_PWM0-&amp;gt;EVENTS_PWMPERIODEND = 1;
// init PPI 
 NRF_PPI-&amp;gt;CH[PWM0_PPI_CH_A].EEP = (uint32_t)&amp;amp;NRF_TIMER3-&amp;gt;EVENTS_COMPARE[TIMER_RELOAD_CC_NUM];
 NRF_PPI-&amp;gt;CH[PWM0_PPI_CH_A].TEP = (uint32_t)&amp;amp;NRF_PWM0-&amp;gt;TASKS_NEXTSTEP;
 NRF_PPI-&amp;gt;CHENSET               = (1 &amp;lt;&amp;lt; PWM0_PPI_CH_A);

}	

// &lt;a href="http://infocenter.nordicsemi.com/pdf/nRF52832_PS_v1.1.pdf"&gt;infocenter.nordicsemi.com/.../nRF52832_PS_v1.1.pdf&lt;/a&gt; page 504 
	
// 47.3 Limitations
// The previous compare value will be repeated if the PWM period is selected to be shorter than the time it
// takes for the EasyDMA to fetch from RAM and update the internal compare registers.
// This is to ensure a glitch-free operation even if very short PWM periods are chosen.

// 47.4 Pin configuration
// The OUT[n] (n=0..3) signals associated to each channel of the PWM module are mapped to
// physical pins according to the configuration specified in the respective PSEL.OUT[n] registers. If a
// PSEL.OUT[n].CONNECT is set to Disconnected, the associated PWM module signal will not be connected
// to any physical pins.
// The PSEL.OUT[n] registers and their configurations are only used as long as the PWM module is enabled
// and PWM generation is active (wave counter started), and retained only as long as the device is in System
// ON mode, see POWER chapter for more information about power modes.
// To ensure correct behaviour in the PWM module, the pins used by the PWM module must be configured in
// the GPIO peripheral as described in Table 117: Recommended GPIO configuration before starting PWM
// generation on page 504 before enabling the PWM module. The pins&amp;#39; idle state is defined by the OUT
// registers in the GPIO module. This is to ensure that the pins used by the PWM module are driven correctly,
// if PWM generation is stopped through a STOP task, the PWM module itself is temporarily disabled, or the
// device temporarily enters System OFF. This configuration must be retained in the GPIO for the selected IOs
// as long as the PWM module is supposed to be connected to an external PWM circuit.
// Only one peripheral can be assigned to drive a particular GPIO pin at a time. Failing to do so may result in
// unpredictable behaviour.


void restart_DMA_generate_test ( uint16_t length_data )
{
  config_pwm_hardware ();
  NRF_PWM0-&amp;gt;SEQ[0].CNT 					= ( length_data &amp;lt;&amp;lt; PWM_SEQ_CNT_CNT_Pos); 
  NRF_PWM0-&amp;gt;TASKS_SEQSTART[0] 	= 1;
  NRF_TIMER3-&amp;gt;TASKS_START 		= 1;	
}`
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the clock pwm frequency is probably incorrectly set?
1kHz frequencies work well&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: NRF52 help configuring TIMER + DMA + PWM</title><link>https://devzone.nordicsemi.com/thread/113704?ContentTypeID=1</link><pubDate>Wed, 20 Dec 2017 15:28:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b687648b-ba0c-40f9-9876-d54a36fd1767</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;Do you have any experience with the TIMER and PPI modules?&lt;/p&gt;
&lt;p&gt;If you configure the PWM in the &lt;em&gt;NextStep&lt;/em&gt; mode it will only read a new value from the buffer once you activate the NEXTSTEP task:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;NRF_PWM0-&amp;gt;TASKS_NEXTSTEP = 1;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;By using the PPI controller you can connect one of the TIMER COMPARE events to the NEXTSTEP task, to have the timer control the PWM update frequency.&lt;/p&gt;
&lt;p&gt;Before you do this you can set up a RAM buffer for the PWM to read from, so that you can run the PWM in the background without having to continuously feed it new data.&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;
Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>