GithubHelp home page GithubHelp logo

0xrocky / stm32f4-discovery Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 5.41 MB

Experiments with the STM32F407VGT6 MCU.

License: GNU General Public License v3.0

C 99.53% Assembly 0.47%
mcu embedded-systems stm32f4-discovery stm32f407vgt6 stmicroelectronics stm32cubemx stm32cubeide

stm32f4-discovery's Introduction

stm32f4-discovery

Experiments with the STM32F407VGT6 MCU.

1. Blinky

Program that, in rotation, turns on and off all the following LEDs on the STM32F4 MCU:

  • user LD3: orange LED is a user LED connected to the I/O PD13 of the STM32F407VGT6
  • user LD4: green LED is a user LED connected to the I/O PD12 of the STM32F407VGT6
  • user LD5: red LED is a user LED connected to the I/O PD14 of the STM32F407VGT6
  • user LD6: blue LED is a user LED connected to the I/O PD15 of the STM32F407VGT6

2. Interrupt

Three exercises for managing an interrupt on EXTI0 (blue button)

The following examples show how to use interrupts to toggle a LED every time we press the user-programmable blue button, which is connected to the PA0 pin:

  1. bare-metal programming
  2. using the ST HAL
  3. using CubeMX

Exercise on nested interrupts (EXTI0 & EXTI1)

Interrupt management with a timer

Prepare a platform with three interrupt sources (I1, I2, I3) each connected to a LED. Write the corresponding interrupt response handlers such that:

  • upon detection of an interrupt signal Ix, 1<= x <= 3, a timer is started
  • if within a predetermined time period T no other interrupt signal is received the LDx is switched on
  • if other interrupts are detected within the predetermined term, all the LEDs corresponding to the interrupts detected will be switched on simultaneously at the end of T

3. printf() with UART/USART

Friends who have studied C should know the standard library functions printf() and scanf(), the former for printing information to the console, and the latter for reading characters from the keyboard to the program. If printf() is called in the program of the microcontroller, where will it be displayed? The answer is unknowable, because the microcontroller does not have a console, but we can use its peripherals to implement printf(), such as LCD or serial port (the serial port is then connected to the computer to display the print information). The serial port is basically the majority of microcontrollers, and the LCD is not necessarily, so we usually use the serial port to print content. So as long as it is a serial port microcontroller, is it possible to print the information by calling printf()?

4. DMA

Two exercises for managing the DMA, in polling and in interrupt.

5. Timer in Input Capture Mode

Application which:

  • set up a GP timer and configure CHx to be input captured on every rising edge of the RCC External Clock Source
  • read (via DMA) the CCRx register and save it to variable T1 on the first edge, on second edge read CCR1 and save it to T2. And now, the input signal's period is T2 – T1, and therefore, the frequency is easily calculated from 1/period
  • configure USART in Async mode and print the calculated frequency to the serial port terminal

6. ADC and Temperature Sensor

Program that acquires data from the built-in temperature sensor using interrupts and:

  • if the detected temperature exceeds 28° C activates the red LED
  • if the temperature drops below 18° C the blue LED lights up
  • for intermediate temperatures the green LED stays on The program also calculates the time taken by the interrupt response routine generated by the ADC circuit.

stm32f4-discovery's People

Contributors

0xrocky avatar

Stargazers

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