Code Monkey home page Code Monkey logo

nucleo-f446re-freertos's Introduction

nucleo-f446re-freertos

This is a collection of projects with a FreeRTOS introduced in the stm32f446re microcontroller from scratch. The board used for testing is the nucleo-f446re.
The repository has a ThirdParty folder, where is placed the code of the FreeRTOS and the SEGGER SystemView (a tool used to debug the FreeRTOS).
On the other hand, each example is coded in a separate folder:

  • 001Tasks: two tasks are executed with nothing to do, only some debug information. You can change the time needed for completing a task using a delay function.
  • 002LEDs: three tasks are executed for controlling the blinking of three LEDs (each task controls one LED). You can use a delay function based on a blocking for loop (so the CPU will be busy in the task until it finishes) or an API (vTaskDelay or vTaskDelayUntil) from freeRTOS to free the CPU when a delay is needed (the task is blocked for an specific amount of time).
  • 003LEDsNotify: three tasks are executed for controlling the blinking of three LEDs (each task controls one LED) one extra task is executed for sensing a button. When the button is pressed one LED is set to ON (if you press the button three times the three LEDs will be set to ON).
  • 004LEDsNotifyISR: the same as the 003 example but the button is managed using an interruption.
  • 005TaskPriority: two tasks with different priority are executed for controlling the same LED. One of the task toggle the LED each 100ms and the other each 1000ms. You can inverts the priority of the tasks pushing a button.
  • 006Queues: five tasks are scheduled for managing four LEDs and the RTC peripheral of the microcontroller.

Compiling

The build enviroment used is CMake, you will find a CMakeLists.txt file and a separate arm_toolchain.cmake file where the cross copilation toolchain is defined. For compiling the project you can do:

mkdir build
cd build
cmake ..
make

Testing

You can use OpenOCD (Open On-Chip Debugger) for programming or debugging this project. You can starting OpenOCD typing:

openocd -f board/st_nucleo_f4.cfg

You can use a telnet connection for connecting to the OpenOCD server:

telnet 127.0.0.1 4444

You can program the microcontroller using:

reset init
flash write_image erase your_app.elf
reset

Debugging

You can use gdb for debug, if your executable file is named foo.elf, you can do:

  • Open a terminal and execute OpenOCD
  • Open other terminal and execute gdb, in the gdb session execute:
target remote localhost:3333
monitor reset init
file foo.elf
tui enable

Other tool you can use is SEGGER SystemView. This tool is already integrated in these projects.
The tool is configured for continuous recording (real time recording) and for sending data using a UART, in this case the USART2 (pins PA2 and PA3) which is the UART connected to the ST-Link USB port.
You need to set SEGGER_UART_REC to 1 in SEGGER_SYSVIEW_Conf.h and the USART is configured in the file segger_uart.c where you need to specify the core clock frequency, peripheral addresses and the IRQ handler of the UART.
When the continuous recording is selected, the SEGGER_SYSVIEW_Start() function does not need to be called because is already used for the segger_uart.c file.
For starting the debug, open SystemView, then select Target->Recorder Cofiguration and select UART, then select ttyACM0 and the configured speed (500000 in these projects). Finally click in the Start Recorder button.

If you use single-shot recording, the recorded debug data for the SEGGER SystemView are stored in a region of RAM memory (these buffers are configured in the SEGGER_RTT_Conf.h), the address of the buffer is __SEGGER_RTT.aUp[1].pBuffer. You need to export the data (RAW Binary) from this memory region to a file (with extension .SVdat) using a debugger. Now You can load this file into the SystemView.
For single-shot recording you do not need to compile the segger_uart.c file, you need to set SEGGER_UART_REC to 0 in SEGGER_SYSVIEW_Conf.h and call SEGGER_SYSVIEW_Start().

nucleo-f446re-freertos's People

Contributors

maherme 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.