Git Product home page Git Product logo

stm32f303k8-template's Introduction

STM32F303K8 cmake template

This is just a cmake template for the stmr32f303k8 mcu. For the development I've used the NUCLEO-F303K8 board. Therefore, if you use another board then you might need to do some modifications. This template project only uses the USART port and a blinking led.

NUCLEO-F303K8

Regarding the NUCLEO-F303K8, the USART2 port, which uses the pins PA2 and PA15 is proxied though the second mcu (stm32f103c8t6). The second mcu is actually the onboard st-link, but it also enumerates a CDC USB interface that proxies the trafic from the stm32f303k8 to your workstation host.

Therefore, if you're using another board, then be aware that you need to change the USART configuration in the main.c.

Clocks

By default this template uses the internal clock (HCI) and the PLL is set to 72MHz. You can easily overclock to 128MHz by changing this line in the main.c:

sysclk_init(SYSCLK_SOURCE_INTERNAL, SYSCLK_72MHz, 1);

to this one:

sysclk_init(SYSCLK_SOURCE_INTERNAL, SYSCLK_128MHz, 1);

In this call, the last argument (in this case 1), is the flag for using safe clocks for the PCLK1 and PCLK2. That means that for frequencies higher than 72MHz the function will take care of the clocks not to exceed the max limits. If it's set to 0 then also the PCLK1 and PCLK2 will be overclocked.

Note: In order to make the overclocking work, I had to modify a line in the standard peripheral library and specificaly in this file source/libs/StdPeriph_Driver/src/stm32f30x_rcc.c. Therefore, in line #876 you'll see that I've removed the HSI_VALUE division with 2.

/* HSI oscillator clock divided by 2 selected as PLL clock entry */
//        pllclk = (HSI_VALUE >> 1) * pllmull;
        pllclk = HSI_VALUE * pllmull;

Build and flash

This project was developed and tested on a Linux machine only. Nevertheless, I've provided also a script for windows machines to build it, but this script is un-tested and it migh not work.

To build the project you need cmake to be installed to your host and also you need an ARM toolchain. The toolchain I've used is:

gcc-arm-none-eabi-7-2017-q4-major

You need to set your toolchain in the cmake/TOOLCHAIN_arm_none_eabi_cortex_m4.cmake file. The current default location is:

set(TOOLCHAIN_DIR /opt/toolchains/gcc-arm-none-eabi-7-2017-q4-major)

Therefore, you need to change this line to point to your toolchain's path.

To build the project run:

./build.sh

To make a clean build and delete all previous builds:

CLEANBUILD=true ./build.sh

Then to flash the bin in the mcu:

./flash.bash

Author

Dimitris Tassopoulos [email protected]

stm32f303k8-template's People

Contributors

dimtass avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.