<?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>Can I make one of the nRF5340 pins oscillate at 12.288MHz? (Audio PLL Clock)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/64903/can-i-make-one-of-the-nrf5340-pins-oscillate-at-12-288mhz-audio-pll-clock</link><description>I&amp;#39;m trying to avoid buying a 12.288MHz oscillator if I can make one of the pins on the nRF5340 oscillate at that frequency. 
 It looks like the ACLK is only available to the PDM and I2S peripherals. 
 Is there a way to make one or both of them use ACLK</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 12 Jan 2023 16:17:32 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/64903/can-i-make-one-of-the-nrf5340-pins-oscillate-at-12-288mhz-audio-pll-clock" /><item><title>RE: Can I make one of the nRF5340 pins oscillate at 12.288MHz? (Audio PLL Clock)</title><link>https://devzone.nordicsemi.com/thread/404638?ContentTypeID=1</link><pubDate>Thu, 12 Jan 2023 16:17:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aa341556-4f14-43c4-ab9c-ce62c3db7e9a</guid><dc:creator>DBT</dc:creator><description>&lt;p&gt;I&amp;#39;m not an expert on I2S using nRF5340.&amp;nbsp; This ticket is about getting the MCLK pin to oscillate.&amp;nbsp; I wasn&amp;#39;t trying to send or receive any I2S data.&lt;/p&gt;
&lt;p&gt;However, at this point I am trying to receive data over I2S, so I&amp;#39;ll probably know more within a few weeks.&lt;/p&gt;
&lt;p&gt;Look at section 7.15.3 &lt;span&gt;in the&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="https://infocenter.nordicsemi.com/pdf/nRF5340_PS_v1.3.pdf"&gt;datasheet&lt;/a&gt;&amp;nbsp;for the discussion about &amp;quot;mono&amp;quot;&lt;/p&gt;
&lt;p&gt;By &amp;quot;left&amp;quot; do you mean left-aligned or the left channel of audio?&amp;nbsp; Look at section 7.15.6 in the &lt;a href="https://infocenter.nordicsemi.com/pdf/nRF5340_PS_v1.3.pdf"&gt;datasheet&lt;/a&gt;.&amp;nbsp; This same section talks about 16-bit wide data.&lt;/p&gt;
&lt;p&gt;I think for 16kHz sampling you&amp;#39;d want to use PCLK32M rather than ACLK as the clock source.&lt;/p&gt;
&lt;p&gt;You&amp;#39;ll probably want to submit a separate ticket in order to get better answers to your specific questions.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can I make one of the nRF5340 pins oscillate at 12.288MHz? (Audio PLL Clock)</title><link>https://devzone.nordicsemi.com/thread/403976?ContentTypeID=1</link><pubDate>Tue, 10 Jan 2023 07:57:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:69d21696-4529-4b26-b188-b4929969d6b8</guid><dc:creator>yoyou</dc:creator><description>&lt;p&gt;Hi,DBT&lt;/p&gt;
&lt;p&gt;how to adjust&amp;nbsp;audio clock to 16bit 16kHz Left mono?&lt;/p&gt;
&lt;p&gt;thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can I make one of the nRF5340 pins oscillate at 12.288MHz? (Audio PLL Clock)</title><link>https://devzone.nordicsemi.com/thread/265188?ContentTypeID=1</link><pubDate>Tue, 18 Aug 2020 17:26:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:807e07fe-1d73-4ea3-a69b-2a6dd080c2d6</guid><dc:creator>DBT</dc:creator><description>&lt;p&gt;That worked.&lt;/p&gt;
&lt;p&gt;Here is the code that makes it work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define I2S_MCK_PIN 7 // MCLK pin is P0.07

#define I2S_DATA_BLOCK_WORDS 512 //How many numbers do we want. time reorded = DATA_BLOCK_WORDS / freq

static u32_t m_buffer_rx32u[I2S_DATA_BLOCK_WORDS];
static nrfx_i2s_buffers_t i2s_initial_buffers;



// I2S ISR handler
ISR_DIRECT_DECLARE(i2s_isr_handler)
{
  nrfx_i2s_irq_handler();
  ISR_DIRECT_PM();  // PM done after servicing interrupt for best latency
  return 1;         // We should check if scheduling decision should be made
}

// I2S event handler
static void i2s_data_handler(nrfx_i2s_buffers_t const *p_released, u32_t status)
{
  if (NRFX_I2S_STATUS_NEXT_BUFFERS_NEEDED == status)
  {
    nrfx_i2s_next_buffers_set(&amp;amp;i2s_initial_buffers);
  }
}

/*****************************************************************************
* Function: i2s_clk_init
*
* Description: provide 12.288MHz reference clock to audio ADC
*
* Parameters: none
*
* Returns: nothing
*****************************************************************************/
static void i2s_clk_init(void)
{
  // the audio clock defaults to 12.288MHz, so we don&amp;#39;t need to adjust it

  // configure I2S
  IRQ_DIRECT_CONNECT(I2S0_IRQn, 0, i2s_isr_handler, 0);
  i2s_initial_buffers.p_rx_buffer = m_buffer_rx32u;

  nrfx_i2s_config_t i2s_cfg = NRFX_I2S_DEFAULT_CONFIG(NRFX_I2S_PIN_NOT_USED, NRFX_I2S_PIN_NOT_USED, I2S_MCK_PIN, NRFX_I2S_PIN_NOT_USED, NRFX_I2S_PIN_NOT_USED);
  i2s_cfg.clksrc = NRF_I2S_CLKSRC_ACLK; // audio clock
  i2s_cfg.enable_bypass = true;         // bypass division, so we get the raw audio clock
  nrfx_err_t err_code = nrfx_i2s_init(&amp;amp;i2s_cfg, i2s_data_handler);

  if(err_code != NRFX_SUCCESS) 
  {
    printf(&amp;quot;Error initializing I2S\n&amp;quot;);
    return;
  }

  // start i2s
  err_code = nrfx_i2s_start(&amp;amp;i2s_initial_buffers, I2S_DATA_BLOCK_WORDS, 0);
  if (err_code != NRFX_SUCCESS)
  {
    printf(&amp;quot;I2S start error\n&amp;quot;);
  }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Can I make one of the nRF5340 pins oscillate at 12.288MHz? (Audio PLL Clock)</title><link>https://devzone.nordicsemi.com/thread/265079?ContentTypeID=1</link><pubDate>Tue, 18 Aug 2020 11:47:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0b4dd55a-4bfc-405f-a3c3-4acce640a954</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;You can output the ACLK by setting the source to ACLK and .BYPASS=1 in this register:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf5340/i2s.html?cp=3_0_0_6_14_9_26#register.CONFIG.CLKCONFIG"&gt;https://infocenter.nordicsemi.com/topic/ps_nrf5340/i2s.html?cp=3_0_0_6_14_9_26#register.CONFIG.CLKCONFIG&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You should then get the ACLK out on the selected MCLK pin. Note that some pins on the nRF5340-PDK are not routed to the pin header (used for other purposes). I took P0.10 for testing.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Note that the ACLK and external HFCLK shall be started prior to enabling and starting the I2S peripheral:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="text"&gt;NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);
NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;

NRF_CLOCK-&amp;gt;TASKS_HFCLKAUDIOSTART = 1;
while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKAUDIOSTARTED == 0);
NRF_CLOCK-&amp;gt;EVENTS_HFCLKAUDIOSTARTED = 0;&lt;/pre&gt;&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>