2018-02-23 01:56 PM
Hello,
There are 2 things I do not understand about my Nucleo-FRM32F042K6 project (attached take1.ioc). As you can see, I turned off everything except the SWD and USB.
I want to use the HSI48 for USB, and run everything else off the HSI, without the PLL. In Mr. Noviello's ''Mastering STM32'' book section 10.1.2 Configuraing Clock Tree Using CubeMX, he uses 8 MHz for APB1 peripheral clock just like I did, but my CubeMX marks the box as red. So far, I haven't found an explanation.
And why does CubeMX want to generate GPIO code, when I am not using any GPIO?
Thanks for reading!
2018-02-23 02:19 PM
You checked: 'set All pins as analog' in code generator option - that's why all unused pins are configured
2018-02-23 03:42 PM
It seems that the dependency is on USB - when you disable USB the 8MHz on APB1 is accepted.
Cannot find any relevant limitation in the datasheet.
2018-02-23 03:53 PM
Thanks for the quick reply Bogdan,
So is it cheaper to choose HSI48 into the clock mux (SW) and divide by 4 to run everything at 12 MHz, or to turn on PLL to generate a 16 MHz from 8 MHz? The power consumption calculator doesn't have an option for HSI48 into the clock mux...
2018-02-23 06:00 PM
>
So is it cheaper to choose HSI48 into the clock mux (SW)
Select in the Cube menu 'Reset' (PCLK1 will become red) then select 'Resolve' and it will automagically find solution.
The PCLK1 in the initial state is red not because of USB (the USB clock Mux is shown below) but because PCKL1 should be > 10 MHz and it was 8.
HSI48 is the internal on-chip source that you get for free.
If you want lower system clock than 48 MHz, try to enter lower values in rectangles with blue frames and resolve again.
>
And why does CubeMX want to generate GPIO code, when I am not using any GPIO?
Even if you have not defined custom GPIOs , CubeMX creates setup code for pins used by various functions such as USB and for unused pins.
-- pa
2018-02-24 08:26 PM
Thanks for the response, Pavel. My question might not have been clear; let me try again.
STM32F042 can indeed generate the 48 MHz internally--HSI48. But it also has 8 MHz HSI and PLL (like many other STM32F devices). A question naturally arises: is it better use HSI to generate every clock in the system? From the data sheet, it seems that the HSI quality is not good enough for USB FS, so one MUST use HSI48 for USB comm. In THAT case then, one wonders: is it better to feed HSI48 to the APB and the MCU, or to still use the HSI? From the behavior of the CubeMX that I observe and answer above, it seems that the USB peripheral needs a minimum of 12 MHz clock on the APB, IN ADDITION to the HSI48 (although I still don't know why the USB peripheral couldn't just divide the input HSI48 by 4 and work independently of the APB1 clock). At this point, it seems I have 2 choices for the APB1 clock generation:
I don't know how to infer which route is more energy efficient from the data sheet. Sorry if I am just ignorant of something that should perhaps be obvious.
Thanks for reading!