You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2020/06/16 00:21:41 UTC

[GitHub] [incubator-nuttx] v01d opened a new pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

v01d opened a new pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252


   ## Summary
   When MSI clock is selected at 48MHz this change is needed to avoid a hang on boot. It appears that setting the MSION bit when already on brought this problem.  
   At the same time, using this higher clock value triggered the selection of the range 1 for core regulator and this also hung during boot. I could not find out why this problem occurs but since this is the default behavior it should introduce any different behavior.
   Finally, with this clock speed there wasn't a matching case for the I2C clocking computations. I used ST's tool to get the values for this case. This now allows using I2C with MSI@48MHz as SYSCLK
   
   ## Impact
   Selection of MSI clock at 48MHz frequency as system clock 
   
   ## Testing
   I'm using I2C at 48MHz with MSI on STM32L476 and can communicate correctly
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-645425744


   @jerpelea I saw this being requested on other PRs. It is quite confusing to me since I was not aware that this was requirement. Is that written somewhere?
   Personally I think that if the requirement is to add a paragraph to every single commit this is a huge added workload. I'm trying to be very detailed and precise in my PR descriptions and I think I use relatively descriptive commit messages. I would appreciate some written guidance on the requirements for PRs so that i don't have to go back on all PRs just to edit every single commit message after the fact. 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-645473363


   I think the comments are fine. I will merge it!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis edited a comment on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
acassis edited a comment on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-645018299


   Ok, it worked on 48MHz MSI.
   
   These are the modification I did:
   
   diff --git a/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h b/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h
   index f6cfbd4d29..1bf31ad33d 100644
   --- a/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h
   +++ b/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h
   @@ -49,11 +49,10 @@
     * Pre-processor Definitions
     ****************************************************************************/
    
   -#if 1
   +#if 0
    #  define HSI_CLOCK_CONFIG          /* HSI-16 clock configuration */
    #elif 0
    /* Make sure you installed one! */
   -
    #  define HSE_CLOCK_CONFIG          /* HSE with 8 MHz xtal */
    #else
    #  define MSI_CLOCK_CONFIG          /* MSI @ 4 MHz autotrimmed via LSE */
   @@ -97,7 +96,7 @@
    #define STM32L4_LSI_FREQUENCY     32000
    #define STM32L4_LSE_FREQUENCY     32768
    
   -#define STM32L4_BOARD_USEHSI      1
   +#define STM32L4_BOARD_USEMSI      1
    
    /* XXX sysclk mux = pllclk */
    
   @@ -206,6 +205,8 @@
     * as per comment above HSI) .
     */
    
   +#define STM32L4_BOARD_NOPLL 1
   +
    #define STM32L4_PLLCFG_PLLM             RCC_PLLCFG_PLLM(1)
    
    /* 'main' PLL config; we use this to generate our system clock via the R
   @@ -252,12 +253,12 @@
    #define STM32L4_PLLSAI2CFG_PLLR         0
    #undef  STM32L4_PLLSAI2CFG_PLLR_ENABLED
    
   -#define STM32L4_SYSCLK_FREQUENCY  80000000ul
   +#define STM32L4_SYSCLK_FREQUENCY  48000000ul
    
    /* CLK48 will come from PLLSAI1 (implicitly Q) */
    
    #define STM32L4_USE_CLK48
   -#define STM32L4_CLK48_SEL         RCC_CCIPR_CLK48SEL_PLLSAI1
   +#define STM32L4_CLK48_SEL         RCC_CCIPR_CLK48SEL_MSI
    
    /* enable the LSE oscillator, used automatically trim the MSI, and for RTC */
    
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-644948366


   I usually use nsh config for testing. Anyway, clock selection requires editing the board header file. You should change the option at the top so that MSI is used. Then, inside the MSI section of that header, you can select MSI frequency by setting:
   
   #define STM32L4_BOARD_MSIRANGE    RCC_CR_MSIRANGE_48M
   
   and further below you should change:
   
   #define STM32L4_SYSCLK_FREQUENCY  48000000ul
   
   I did my tests using MSI as the main clock so you should disable the PLL with:
   
   #define STM32L4_BOARD_NOPLL
   
   Then choose sysclk by changing this line to:
   
   #define STM32L4_CLK48_SEL         RCC_CCIPR_CLK48SEL_MSI
   
   BTW, to my understanding all those "2*" on CLKIN definitions are not correct. I don't understand where that comes from, since the prescaler for peripheral clocks is clearly not divided by 2 as the comments a few lines above state. Anyway, it should not affect you.
   
   I think clock configuration should really be possible via menuconfig, I might work on that sometime.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis edited a comment on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
acassis edited a comment on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-645018299


   Ok, it worked on 48MHz MSI.
   
   These are the modification I did:
   
   `diff --git a/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h b/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h
   index f6cfbd4d29..1bf31ad33d 100644
   --- a/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h
   +++ b/boards/arm/stm32l4/nucleo-l476rg/include/nucleo-l476rg.h
   @@ -49,11 +49,10 @@
     * Pre-processor Definitions
     ****************************************************************************/
    
   -#if 1
   +#if 0
    #  define HSI_CLOCK_CONFIG          /* HSI-16 clock configuration */
    #elif 0
    /* Make sure you installed one! */
   -
    #  define HSE_CLOCK_CONFIG          /* HSE with 8 MHz xtal */
    #else
    #  define MSI_CLOCK_CONFIG          /* MSI @ 4 MHz autotrimmed via LSE */
   @@ -97,7 +96,7 @@
    #define STM32L4_LSI_FREQUENCY     32000
    #define STM32L4_LSE_FREQUENCY     32768
    
   -#define STM32L4_BOARD_USEHSI      1
   +#define STM32L4_BOARD_USEMSI      1
    
    /* XXX sysclk mux = pllclk */
    
   @@ -206,6 +205,8 @@
     * as per comment above HSI) .
     */
    
   +#define STM32L4_BOARD_NOPLL 1
   +
    #define STM32L4_PLLCFG_PLLM             RCC_PLLCFG_PLLM(1)
    
    /* 'main' PLL config; we use this to generate our system clock via the R
   @@ -252,12 +253,12 @@
    #define STM32L4_PLLSAI2CFG_PLLR         0
    #undef  STM32L4_PLLSAI2CFG_PLLR_ENABLED
    
   -#define STM32L4_SYSCLK_FREQUENCY  80000000ul
   +#define STM32L4_SYSCLK_FREQUENCY  48000000ul
    
    /* CLK48 will come from PLLSAI1 (implicitly Q) */
    
    #define STM32L4_USE_CLK48
   -#define STM32L4_CLK48_SEL         RCC_CCIPR_CLK48SEL_PLLSAI1
   +#define STM32L4_CLK48_SEL         RCC_CCIPR_CLK48SEL_MSI
    
    /* enable the LSE oscillator, used automatically trim the MSI, and for RTC */
    
   `
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-645018299


   Ok, it worked on 48MHz MSI.
   
   These are the modification I did:
   
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis merged pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
acassis merged pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] v01d commented on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
v01d commented on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-644949223


   You can also try other frequencies, but if you're using I2C, I think only other clock option is 16MHz since otherwise I2C timings are not yet defined. But UART should work.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis commented on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
acassis commented on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-644945027


   Hi Matias, do you have a defconfig that I could use to test it on nucleo-l476rg board?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] acassis edited a comment on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
acassis edited a comment on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-645018299


   Ok, it worked on 48MHz MSI.
   
   These are the modification I did:
   
   https://pastebin.com/00PW2cvL
   
   Pasting code here doesn't work, even using the "Insert code" button.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] jerpelea commented on pull request #1252: STM32L4: fix 48MHz MSI clock selection logic

Posted by GitBox <gi...@apache.org>.
jerpelea commented on pull request #1252:
URL: https://github.com/apache/incubator-nuttx/pull/1252#issuecomment-645190392


   @v01d Please add commit messages for all commits 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org