[En-Nut-Discussion] stm32f1_clk.c set systemclock for PLL *6.5

kontais kontais at aliyun.com
Tue Mar 15 07:35:45 CET 2016


Hi Uwe,
    When a use Makefile.cm3-gccdbg to make a debug file, I get the error output bellow.
the error line is deal with STM32F105x and STM32F107x system clock(PLL input clock x 6.5), need move
down after pllinput value set. 

arm-none-eabi-gcc -c -I../.././nutbld/include  -I../.././nut/include -I../.././n
ut/include/contrib  -DNUT_THREAD_STACK_MULT=3 -DSHENZHOU_IV  -MD -MP -mcpu=corte
x-m3 -mthumb -D__CORTEX__  -ffunction-sections -fdata-sections -fomit-frame-poin
ter -mfix-cortex-m3-ldrd -O0 -g3 -Wall -Wstrict-prototypes -fverbose-asm -Wa,-ah
lms=../.././nut/arch/cm3/dev/stm/stm32f1_clk.lst  -Wall -Wstrict-prototypes -Wer
ror -Wa,-a=cm3/dev/stm/stm32f1_clk.lst   -o cm3/dev/stm/stm32f1_clk.o ../.././nu
t/arch/cm3/dev/stm/stm32f1_clk.c
../.././nut/arch/cm3/dev/stm/stm32f1_clk.c: In function 'SystemCoreClockUpdate':

../.././nut/arch/cm3/dev/stm/stm32f1_clk.c:278:30: error: 'pllinput' may be used
 uninitialized in this function [-Werror=maybe-uninitialized]
                     pllinput = pllinput / 2;
                              ^
cc1.exe: all warnings being treated as errors
make[1]: *** [cm3/dev/stm/stm32f1_clk.o] 错误 1
make[1]: Leaving directory `E:/ethernut_code_patch/nutbld/arch'
make: *** [all] 错误 2


stm32f1_clk.patch

1. pllmult = pllmult / RCC_CFGR_PLLMULL_0;
    -->pllmult = (pllmult / RCC_CFGR_PLLMULL_0) + 2;

2. Move bellow pllinput value set
 # if defined(RCC_CFGR_PLLMULL6_5)
                if ((RCC->CFGR & RCC_CFGR_PLLMULL) == RCC_CFGR_PLLMULL6_5) {
                    pllinput = pllinput / 2;
                    pllmult = 13;
                }
 # endif

3. Not use, error code
 # if defined (RCC_CFGR2_PREDIV1)
            if (RCC_CFGR_PLLSRC != pllsource) {
                uint32_t prediv1factor;
                prediv1factor = RCC->CFGR2 & RCC_CFGR2_PREDIV1;
                /* HSE oscillator clock selected as PREDIV1 clock entry */
                pllinput = HSE_VALUE / (prediv1factor + 1);
            }
 #endif
   
4. Calculate sys_clock
   sys_clock = pllinput * (pllmult + 2);
    --> sys_clock = pllinput * pllmult;




More information about the En-Nut-Discussion mailing list