<?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>LPC Microcontrollersのトピック[LPC55S69] tempature sensor example: how to modify boot clock from PLL1 to PLL0</title>
    <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-tempature-sensor-example-how-to-modify-boot-clock-from/m-p/1697391#M53683</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get help from anyone about the temperature sensor example.&lt;/P&gt;&lt;P&gt;Currently, my code uses PLL0_150M() for the boot clock, but the example requires to use PLL1_150M() for the boot clock.&lt;/P&gt;&lt;P&gt;This causes an error (15: target error from register access) when I kept using PLL0_150() with ADC initialization. It seems that the initialization for ADC, which is below, is trying to change PLL0 even though it was set during the boot.&lt;/P&gt;&lt;P&gt;I also tried to use PLL1 for the boot, but it led to unexpected behavior in other parts of my code.&lt;/P&gt;&lt;P&gt;It would be best if you can guide me to modify the below code properly.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    /* Maximum advised frequency for temperature sensor measurement is 6MHz whether the source is XTAL or FRO.
     * However, the ADC clock divider value is in the range from 1 to 8, so the PLL0(attached to 16MHZ XTAL)
     * is selected as the ADC clock source with ADC clock divider value as 4.
     */
    /*!&amp;lt; Set up PLL */
    CLOCK_AttachClk(kEXT_CLK_to_PLL0);  /*!&amp;lt; Switch PLL0CLKSEL to EXT_CLK */
    POWER_DisablePD(kPDRUNCFG_PD_PLL0); /* Ensure PLL is on  */
    POWER_DisablePD(kPDRUNCFG_PD_PLL0_SSCG);
    const pll_setup_t pll0Setup = {
        .pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI(19U) | SYSCON_PLL0CTRL_SELP(9U),
        .pllndec = SYSCON_PLL0NDEC_NDIV(1U),
        .pllpdec = SYSCON_PLL0PDEC_PDIV(16U),
        .pllsscg = {0x0U, (SYSCON_PLL0SSCG1_MDIV_EXT(32U) | SYSCON_PLL0SSCG1_SEL_EXT_MASK)},
        .pllRate = 16000000U,
        .flags   = PLL_SETUPFLAG_WAITLOCK};
    CLOCK_SetPLL0Freq(&amp;amp;pll0Setup);

    CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 0U, true);  /*!&amp;lt; Reset ADCCLKDIV divider counter and halt it */
    CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 4U, false); /*!&amp;lt; Set ADCCLKDIV divider to value 4 */

    CLOCK_AttachClk(kPLL0_to_ADC_CLK); /*!&amp;lt; Switch ADC_CLK to PLL0 */

    /* Disable LDOGPADC power down */
    POWER_DisablePD(kPDRUNCFG_PD_LDOGPADC);
    /* Disable Temperature sensor power down. */
    POWER_DisablePD(kPDRUNCFG_PD_TEMPSENS);

    ANACTRL_Init(ANACTRL);
    ANACTRL_EnableVref1V(ANACTRL, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint/guide/instruction would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Mat&lt;/P&gt;</description>
    <pubDate>Wed, 02 Aug 2023 08:36:48 GMT</pubDate>
    <dc:creator>mat1024</dc:creator>
    <dc:date>2023-08-02T08:36:48Z</dc:date>
    <item>
      <title>[LPC55S69] tempature sensor example: how to modify boot clock from PLL1 to PLL0</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-tempature-sensor-example-how-to-modify-boot-clock-from/m-p/1697391#M53683</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to get help from anyone about the temperature sensor example.&lt;/P&gt;&lt;P&gt;Currently, my code uses PLL0_150M() for the boot clock, but the example requires to use PLL1_150M() for the boot clock.&lt;/P&gt;&lt;P&gt;This causes an error (15: target error from register access) when I kept using PLL0_150() with ADC initialization. It seems that the initialization for ADC, which is below, is trying to change PLL0 even though it was set during the boot.&lt;/P&gt;&lt;P&gt;I also tried to use PLL1 for the boot, but it led to unexpected behavior in other parts of my code.&lt;/P&gt;&lt;P&gt;It would be best if you can guide me to modify the below code properly.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    /* Maximum advised frequency for temperature sensor measurement is 6MHz whether the source is XTAL or FRO.
     * However, the ADC clock divider value is in the range from 1 to 8, so the PLL0(attached to 16MHZ XTAL)
     * is selected as the ADC clock source with ADC clock divider value as 4.
     */
    /*!&amp;lt; Set up PLL */
    CLOCK_AttachClk(kEXT_CLK_to_PLL0);  /*!&amp;lt; Switch PLL0CLKSEL to EXT_CLK */
    POWER_DisablePD(kPDRUNCFG_PD_PLL0); /* Ensure PLL is on  */
    POWER_DisablePD(kPDRUNCFG_PD_PLL0_SSCG);
    const pll_setup_t pll0Setup = {
        .pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI(19U) | SYSCON_PLL0CTRL_SELP(9U),
        .pllndec = SYSCON_PLL0NDEC_NDIV(1U),
        .pllpdec = SYSCON_PLL0PDEC_PDIV(16U),
        .pllsscg = {0x0U, (SYSCON_PLL0SSCG1_MDIV_EXT(32U) | SYSCON_PLL0SSCG1_SEL_EXT_MASK)},
        .pllRate = 16000000U,
        .flags   = PLL_SETUPFLAG_WAITLOCK};
    CLOCK_SetPLL0Freq(&amp;amp;pll0Setup);

    CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 0U, true);  /*!&amp;lt; Reset ADCCLKDIV divider counter and halt it */
    CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 4U, false); /*!&amp;lt; Set ADCCLKDIV divider to value 4 */

    CLOCK_AttachClk(kPLL0_to_ADC_CLK); /*!&amp;lt; Switch ADC_CLK to PLL0 */

    /* Disable LDOGPADC power down */
    POWER_DisablePD(kPDRUNCFG_PD_LDOGPADC);
    /* Disable Temperature sensor power down. */
    POWER_DisablePD(kPDRUNCFG_PD_TEMPSENS);

    ANACTRL_Init(ANACTRL);
    ANACTRL_EnableVref1V(ANACTRL, true);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any hint/guide/instruction would be greatly appreciated.&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Mat&lt;/P&gt;</description>
      <pubDate>Wed, 02 Aug 2023 08:36:48 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-tempature-sensor-example-how-to-modify-boot-clock-from/m-p/1697391#M53683</guid>
      <dc:creator>mat1024</dc:creator>
      <dc:date>2023-08-02T08:36:48Z</dc:date>
    </item>
    <item>
      <title>Re: [LPC55S69] tempature sensor example: how to modify boot clock from PLL1 to PLL0</title>
      <link>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-tempature-sensor-example-how-to-modify-boot-clock-from/m-p/1698887#M53709</link>
      <description>&lt;P class="lia-align-justify"&gt;Hello &lt;a href="https://community.nxp.com/t5/user/viewprofilepage/user-id/204744"&gt;@mat1024&lt;/a&gt;,&lt;/P&gt;
&lt;P class="lia-align-justify" data-unlink="true"&gt;The section of the code you are referring is setting the clock source of the ADC. &lt;A href="https://www.nxp.com/products/processors-and-microcontrollers/arm-microcontrollers/general-purpose-mcus/lpc5500-arm-cortex-m33/high-efficiency-arm-cortex-m33-based-microcontroller-family:LPC55S6x" target="_self"&gt;LPC55S6x/LPC55S2x/LPC552x&amp;nbsp;Reference Manual&lt;/A&gt;. Chapter 39. LPC55S6x/LPC55S2x/LPC552x 16-bit ADC controller. Section 39.7.4. Clock operation mentions that the clock sources for ADC are: &lt;EM&gt;MAIN_CLK&lt;/EM&gt;, &lt;EM&gt;PLL0&lt;/EM&gt;, &lt;EM&gt;FRO_HF&lt;/EM&gt; and &lt;EM&gt;FRO1M&lt;/EM&gt;. The example is using the &lt;EM&gt;PLL0&lt;/EM&gt; as its source clock.&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;If you want to use &lt;EM&gt;PLL0&lt;/EM&gt; as your boot clock, you could select the &lt;EM&gt;MAIN_CLK&lt;/EM&gt; as your ADC's clock source. Next, we share you a possible modification to use &lt;EM&gt;BOARD_BootClockPLL150M()&lt;/EM&gt; and &lt;EM&gt;MAIN_CLK&lt;/EM&gt; instead of &lt;EM&gt;BOARD_BootClockPLL1_150M()&lt;/EM&gt; and &lt;EM&gt;PLL0&lt;/EM&gt;.&lt;/P&gt;
&lt;P class="lia-align-justify"&gt;In lpadc_temperature_measurement.c's &lt;EM&gt;main()&lt;/EM&gt; be sure to place the following:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;BOARD_InitBootPins();
BOARD_BootClockPLL150M();
BOARD_InitDebugConsole();

//Suggested changes
CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 0U, true);  /*!&amp;lt; Reset ADCCLKDIV divider counter and halt it */
CLOCK_SetClkDiv(kCLOCK_DivAdcAsyncClk, 4U, false); /*!&amp;lt; Set ADCCLKDIV divider to value 4 */
CLOCK_AttachClk(kMAIN_CLK_to_ADC_CLK); /*!&amp;lt; Switch ADC_CLK to MAIN_CLK */

/* Disable LDOGPADC power down */
POWER_DisablePD(kPDRUNCFG_PD_LDOGPADC);
/* Disable Temperature sensor power down. */
POWER_DisablePD(kPDRUNCFG_PD_TEMPSENS);&lt;/LI-CODE&gt;
&lt;P class="lia-align-justify"&gt;In clock_config.c's &lt;EM&gt;BOARD_BootClockPLL150M()&lt;/EM&gt; change the &lt;EM&gt;Set up PLL&lt;/EM&gt; as follows:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;/*!&amp;lt; Set up PLL */
CLOCK_AttachClk(kEXT_CLK_to_PLL0);       /*!&amp;lt; Switch PLL0CLKSEL to EXT_CLK */
POWER_DisablePD(kPDRUNCFG_PD_PLL0);                   /* Ensure PLL is on  */
POWER_DisablePD(kPDRUNCFG_PD_PLL0_SSCG);
const pll_setup_t pll0Setup = {
       .pllctrl = SYSCON_PLL0CTRL_CLKEN_MASK | SYSCON_PLL0CTRL_SELI(53U) | SYSCON_PLL0CTRL_SELP(31U),
        .pllndec = SYSCON_PLL0NDEC_NDIV(8U),
        .pllpdec = SYSCON_PLL0PDEC_PDIV(1U),
        .pllsscg = {0x0U,(SYSCON_PLL0SSCG1_MDIV_EXT(150U) | SYSCON_PLL0SSCG1_SEL_EXT_MASK)},
        .pllRate = 150000000U,
        .flags =  PLL_SETUPFLAG_WAITLOCK
    };
CLOCK_SetPLL0Freq(&amp;amp;pll0Setup);   /*!&amp;lt; Configure PLL0 to the desired values */&lt;/LI-CODE&gt;
&lt;P class="lia-align-justify"&gt;Best regards, Raul.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Aug 2023 20:31:51 GMT</pubDate>
      <guid>https://community.nxp.com/t5/LPC-Microcontrollers/LPC55S69-tempature-sensor-example-how-to-modify-boot-clock-from/m-p/1698887#M53709</guid>
      <dc:creator>RaRo</dc:creator>
      <dc:date>2023-08-03T20:31:51Z</dc:date>
    </item>
  </channel>
</rss>

