<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis MicrocontrollersのトピックRe: OSC doesn't appear to be running</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/OSC-doesn-t-appear-to-be-running/m-p/1255030#M60052</link>
    <description>&lt;P&gt;I figured it out. &amp;nbsp;It was the HGO, RANGE and EREFS bits in the MCG_C2 register that were wrong. &amp;nbsp;For the FRDMK22FUG board, HGO is off, RANGE is set to high frequency (0x1) and EREFS bit is set. &amp;nbsp;Now I can see the OSCINIT0 bit set in MCG_S and the UART is working. &amp;nbsp;I'm also seeing an 8 MHz clock on CLKOUT as I would expect.&lt;/P&gt;</description>
    <pubDate>Wed, 31 Mar 2021 14:56:13 GMT</pubDate>
    <dc:creator>JBM</dc:creator>
    <dc:date>2021-03-31T14:56:13Z</dc:date>
    <item>
      <title>OSC doesn't appear to be running</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/OSC-doesn-t-appear-to-be-running/m-p/1253785#M60026</link>
      <description>&lt;P&gt;I am trying to get the LPUART clocked from the OSC using a FRDMK22FUG board (MK22FN512VLH12 processor). &amp;nbsp;The schematic for this board shows an 8 MHz crystal connected to XTAL0 and EXTAL0. &amp;nbsp;I have the LPUART transmitting from the PLLFLLSEL clock source, but when I switch to the OSCERCLK source, nothing is transmitted.&lt;/P&gt;&lt;P&gt;It's very simple code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;int main(void)
{
#if 0
  SIM_SOPT2 = (SIM_SOPT2 &amp;amp; ~SIM_SOPT2_LPUARTSRC_MASK) | SIM_SOPT2_LPUARTSRC(SIM_SOPT2_LPUARTSRC_OSCERCLK);
#else
  SIM_SOPT2 = (SIM_SOPT2 &amp;amp; ~SIM_SOPT2_LPUARTSRC_MASK) | SIM_SOPT2_LPUARTSRC(SIM_SOPT2_LPUARTSRC_PLLFLLSEL);
#endif

  OSC_CR    = OSC_CR_ERCLKEN_MASK | OSC_CR_EREFSTEN_MASK |
              OSC_CR_SC16P_MASK | OSC_CR_SC4P_MASK | OSC_CR_SC2P_MASK;
  OSC_DIV   = 0;

  /*  */
  ports_init();

  /* Configure UART */
  lpuart_init();

  while(true)
  {
    lpuart_transmit("UUUUUUUUUUUUUUUUUUUUUUU");
    for(int i = 0; i &amp;lt; 1000000; i++) {}
  }
  return 0;
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;//
// SOPT2 LPUART clock sources
//
#define SIM_SOPT2_LPUARTSRC_CLOCK_DISABLED      (0x00)
#define SIM_SOPT2_LPUARTSRC_PLLFLLSEL           (0x01)
#define SIM_SOPT2_LPUARTSRC_OSCERCLK            (0x02)
#define SIM_SOPT2_LPUARTSRC_MCGIRCLK            (0x03)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ports_init() is just:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;/*
 * Initialize all ports
 */
void ports_init(void)
{
	/* Enable port clocking */
	SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTD_MASK);

	/*
	 * Port A
	 */
	PORTA-&amp;gt;PCR[PORT_EXTAL0]       = PORT_PCR_MUX(GPIO_PCR_MUX_ANALOG);
	PORTA-&amp;gt;PCR[PORT_XTAL0]        = PORT_PCR_MUX(GPIO_PCR_MUX_ANALOG);

  /*
   * Port D
   */
  PORTD-&amp;gt;PCR[PORT_LPUART0_RX]  = PORT_PCR_MUX(GPIO_PCR_MUX_ALT6);
  PORTD-&amp;gt;PCR[PORT_LPUART0_TX]  = PORT_PCR_MUX(GPIO_PCR_MUX_ALT6);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where&amp;nbsp;PORT_EXTAL0 is defined as 18 and PORT_XTAL0 is defined as 19. &amp;nbsp;GPIO_PCR_MUX_ANALOG is 0.&lt;/P&gt;&lt;P&gt;The lpuart commands are defined as:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#define LPUART_OSR        (16)
#define LPUART_SBR        (49)

/*
 *
 */
void lpuart_init(void)
{
  SIM_SCGC6    |= SIM_SCGC6_LPUART0_MASK;

  LPUART0_BAUD  = LPUART_BAUD_OSR(LPUART_OSR) |
                  LPUART_BAUD_SBR(LPUART_SBR);

  LPUART0_CTRL |= LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK;
}

/*
 *
 */
void lpuart_transmit(uint8_t* data)
{
  while (*data)
  {
    while (!(LPUART0_STAT &amp;amp; LPUART_STAT_TC_MASK)) {}
    LPUART0_DATA = *data;
    data++;
  }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried different capacitance settings in OSC_CR and tried to see if it's oscillating with an oscilloscope, but I don't see anything (it may be that the scope probe stops the oscillation, don't know).&lt;/P&gt;&lt;P&gt;I'm attempting to work toward a low power solution where the LPUART is running all the time, waking the processor when data is received. &amp;nbsp;My first step is what I'm trying here to get the LPUART running from the external clock so that I can put the core in a sleep mode.&lt;/P&gt;&lt;P&gt;I directed OSCERCLK0 (don't know why the zero is on there in the reference manual) to PTC3/ALT5, CLKOUT and I don't see anything. &amp;nbsp;If I direct the flash clock to PTC3, I can see a ~10.5 MHz clock so I know the port is working.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 29 Mar 2021 21:40:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/OSC-doesn-t-appear-to-be-running/m-p/1253785#M60026</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2021-03-29T21:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: OSC doesn't appear to be running</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/OSC-doesn-t-appear-to-be-running/m-p/1255030#M60052</link>
      <description>&lt;P&gt;I figured it out. &amp;nbsp;It was the HGO, RANGE and EREFS bits in the MCG_C2 register that were wrong. &amp;nbsp;For the FRDMK22FUG board, HGO is off, RANGE is set to high frequency (0x1) and EREFS bit is set. &amp;nbsp;Now I can see the OSCINIT0 bit set in MCG_S and the UART is working. &amp;nbsp;I'm also seeing an 8 MHz clock on CLKOUT as I would expect.&lt;/P&gt;</description>
      <pubDate>Wed, 31 Mar 2021 14:56:13 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/OSC-doesn-t-appear-to-be-running/m-p/1255030#M60052</guid>
      <dc:creator>JBM</dc:creator>
      <dc:date>2021-03-31T14:56:13Z</dc:date>
    </item>
  </channel>
</rss>

