1
\$\begingroup\$

Does anyone know of a code template to properly configure clocks, PLL, latency, etc. for the STM32L4x parts? I'm using a NUCLEO board with this part (L476RG) and have struggled for days with the datasheet in vain to learn how to set up the clocks before even beginning to write a "blinky" program to toggle a port pin.

I know of ST's CubeMX program but I'm using the MikroElectronika mikroC compiler (for which CubeMX doesn't produce native output). Tried that and failed too. Anyone have a clue how I might get traction here?

\$\endgroup\$
  • 1
    \$\begingroup\$ You could inspect the code produced by CubeMX. Line by line, check what the function calls do, recursively "expanding" that into register writes. \$\endgroup\$ – Tibo Jan 9 '18 at 19:58
  • 1
    \$\begingroup\$ You shouldn't need to do any clock configuration to get a blinky program working. The default clock on startup is the HSI and the chip will work fine on this. \$\endgroup\$ – Jon Jan 9 '18 at 21:13
  • 1
    \$\begingroup\$ @Jon the default clock is the MSI in the L4xx parts. \$\endgroup\$ – Arsenal Jan 9 '18 at 21:35
  • \$\begingroup\$ While trying to set up STM32L486 from scratch, the one gotcha that I found was that you have to make sure to power up the ports, like e.g. GPIOA etc. banks. Otherwise, no blinkies! \$\endgroup\$ – Pål-Kristian Engstad Jan 10 '18 at 1:22
  • \$\begingroup\$ Either use the cubemx package or the clock configuration excel sheet that is used for some processors. \$\endgroup\$ – laptop2d Aug 8 '18 at 15:50
0
\$\begingroup\$

Download the STM32CubeL4 package, which includes example projects for your board and others. The example projects will include code for setting up the clock and PLL. There are pre-made projects for IAR EWARM, MDK-ARM, Atollic TrueStudio but you'll have to create your own project and port for MikroElectronika mikroC.

The STM32Cube example projects use ST's HAL and/or Low-Level (LL) libraries. The library source code is included so even if you don't want to use the libraries in your application then you can still refer to the library source code as an example.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.