This programming manual is providing the complete details of programming the STM32 Value-line discovery (a low-cost) evaluation board for Value-line of STM32 microcontrollers from STMicroelectronics.
This document provides an introduction to the ARM-7 microprocessor architecture. It describes key features of the ARM7TDMI including its 32-bit RISC instruction set, 3-stage pipeline, 37 registers including separate registers for different processor modes, and low power consumption. The document also compares RISC and CISC architectures and summarizes the different versions of the ARM architecture.
This presentation is made as a part of our udemy course on STM32 MCUs and peripherals. The ppt covers STM32 Reset and Clock Control unit of the STM32 , different types of clock sources such as HSE (High Speed External crystal), HSI (Internal High Speed RC ), PLL concepts,HSI calibration , HCLK,PLCKx and others.
To enroll for our video courses on Microcontroller Programming, RTOS programming, Embedded linux, Bootloader development
visit here : www.fastbitlab.com
youtube : https://www.youtube.com/channel/UCa1REBV9hyrzGp2mjJCagBg
This project will provides a detailed explanation about a smart traffic light controller using verilog code along with test bench and the working principle and simulation outputs are been attached.
A VLSI (Very Large Scale Integration) system integrates millions of “electronic components” in a small area (few mm2 few cm2).
design “efficient” VLSI systems that has:
Circuit Speed ( high )
Power consumption ( low )
Design Area ( low )
RS-232 is a popular communications interface for connecting modems and data acquisition devices (i.e. GPS receivers, electronic balances, data loggers, ...) to computers.
This document discusses an ESP32-CAM development board and provides examples for using its camera functionality. It begins with an introduction to the ESP32 and ESP32-CAM, then describes installing the Arduino SDK. It presents two camera examples: a time-lapse camera that saves photos to an SD card, and a camera web server. It concludes by asking what next steps could be taken.
This document provides information about an embedded systems course offered at Maharajas Technological Institute. It includes details like the course code, credits, syllabus modules covering AVR microcontrollers and programming in assembly and C languages. It also discusses concepts like microcontrollers, AVR architecture, memory organization and instruction set of AVR microcontrollers. Examples are given of assembly language instructions like MOV, LDI, STS etc. and applications of embedded systems in various domains.
Lcd module interface with xilinx software using verilogsumedh23
This document describes a design that interfaces an LCD display to an FPGA board. This allows the data displayed on the LCD to be flexible and configurable through the FPGA, rather than being static. The design implements a multi UART serial communication block with configurable baud rates to interface between the FPGA and LCD. The UART and LCD driver are developed in Verilog and can be integrated into the FPGA. As a proof of concept, the design displays "HELLO WORLD" on the LCD. The RTL code is synthesized and implemented on a Xilinx Spartan FPGA board with the LCD.
The document provides an overview of the ARM architecture, including:
- ARM was founded in 1990 and licenses its processor core intellectual property to design partners.
- The ARM instruction set includes 32-bit ARM and 16-bit Thumb instructions. ARM supports different processor modes like user mode, IRQ mode, and FIQ mode.
- Popular ARM processors include ARM7 and Cortex-M series. ARM licenses its IP to semiconductor companies who integrate the cores into various end products.
Low power VLSI design has become an important discipline due to increasing device densities, operating frequencies, and proliferation of portable electronics. Power dissipation, which was previously neglected, is now a primary design constraint. There are several sources of power dissipation in CMOS circuits, including switching power due to charging and discharging capacitances, short-circuit power during signal transitions, and leakage power from subthreshold and gate leakage currents. Designers have some control over power consumption by optimizing factors such as activity levels, clock frequency, supply voltage, transistor sizing and architecture.
Task and Function is the basic component of a programming language. Even on hardware Verification , those task and function is used. Task ans function provides a short way to repeatedly use the same block of code many times, This presentation gives you the basic information about Task and Function in Verilog. For more information on this, kindly contact us.
This document provides an introduction to PIC microcontrollers. It discusses the architecture of PIC microcontrollers, including the 16C6x and 16C7x architectures. It describes the registers, memory, and instruction set of PIC microcontrollers. Some key points covered include the Harvard architecture, pipelining, addressing modes, arithmetic, logical, and conditional instructions. Peripherals like timers and interrupts are also mentioned.
Fan in and Fan out related to vlsi design basic circuit concepts. This will be used for IC design process. By using such key methods, the performance of the circuit in IC will be improved in a better manner.
The document discusses FPGA design flow and programming. It describes the roles of the systems architect who defines high-level requirements and provides a golden model and test vectors. The FPGA designer is responsible for delivering a firmware that approximates the golden model on a hardware platform using vendor tools. The design flow includes simulation, synthesis, placement and routing, and testing at different stages to verify functionality and timing.
This Presentation describes the ARM CORTEX M3 core processor with the details of the core peripherals. Soon a CORTEX base controller(STM32F100RBT6) ppt will be uploaded. For more information mail me at:[email protected].
Module 2 ARM CORTEX M3 Instruction Set and ProgrammingAmogha Bandrikalli
This document provides an overview of the ARM Cortex M3 instruction sets and assembly programming. It begins by explaining why assembly is commonly used, including the need for detailed control flow and efficiency. The outline presented covers assembly basics, instructions, useful instructions, and assembly and C language programming. It then discusses the various instruction sets of the Cortex M3 with examples. Specific instructions covered include data processing, branch, load/store, and 32-bit instructions. It also notes instructions not supported by the Cortex M3 such as coprocessor, state change, and hint instructions.
The document discusses System on Chips (SoCs). It begins by outlining Moore's Law and how IC technology has scaled over time. This has enabled more system components to be integrated onto a single chip to create SoCs. The document then discusses trends in IC technology like technology scaling, system-on-a-chip, embedded systems, and time-to-market pressures. It provides examples of SoC applications and describes the SoC design process involving hardware-software co-design and reuse of intellectual property cores. In conclusion, the document defines an SoC as an integrated circuit that implements most or all functions of an electronic system on a single chip.
This document discusses printed circuit board (PCB) design. It begins with an introduction to PCBs, describing how they mechanically support and electrically connect electronic components using conductive tracks on insulating substrates. It then discusses the basic materials that make up PCBs like copper foil and plating. The document outlines the main fabrication steps for PCBs which include setting up, imaging, etching, drilling, masking, and electrical testing. It also describes the characteristics of through-hole and surface mount technology. The etching and assembly processes are explained in more detail. Finally, the document provides an overview of PCB design and routing software like EAGLE and includes an example of a power supply board.
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONSDr.YNM
Dr. Y.Narasimha Murthy Ph.D introduces programmable logic devices and their evolution from PLDs to CPLDs and FPGAs. The document discusses the basic architecture and applications of ROM, RAM, PLDs including PLA, PAL and GAL. It provides details on the programmable AND and OR planes in a PLA and compares device types based on their AND and OR array programmability. SPLDs, CPLDs and FPGAs are the main types of PLDs discussed.
Join this video course on udemy . Click here :
https://www.udemy.com/microcontroller-programming-stm32-timers-pwm-can-bus-protocol/?couponCode=SLIDESHARE
learn STM32 TIMERS, CAN,RTC, PWM,LOW POWER embedded systems and program them using STM32 Device HAL APIs STEP by STEP
>>Welcome to the course which teaches you advanced Micro-controller programming. In this course you are going to learn and master TIMERS, PWM, CAN, RTC, LOW POWER MODES of STM32F4x Micro-controller with step by step guidance. Highly recommended if you are seeking a career in the domain of Embedded software. <<
In this course, you will understand behind the scene working of peripherals with supportive code exercises. I have included various real-time exercises which help you to master every peripheral covered in this course and this course thoroughly covers both theory and practical aspects of TIMERS, PWM, CAN, RTC, LOW POWER MODES of STM32F4x Micro-controller.
FPGAs can be programmed after manufacturing to implement custom logic functions. They contain programmable logic blocks and interconnects that can be configured to create custom circuits. FPGAs provide flexibility compared to ASICs but have higher per-unit costs. The FPGA architecture consists of configurable logic blocks, programmable interconnects, and I/O blocks. Configurable logic blocks contain LUTs that implement logic functions. Programmable interconnects connect the logic blocks, and I/O blocks interface with external components. FPGAs are commonly used for prototyping, emulation, parallel computing, and other applications that require customizable hardware.
Flash Bootloader Solutions For ECU Re-Programming: Embitel is expertise in providing solutions and services for Flash bootloader development and ECU re-programming in automotive industry.
This document discusses interfacing digital-to-analog converters (DACs) and sensors with PIC microcontrollers. It introduces DACs and common DAC types like R-2R ladder and weighted resistor DACs. It then discusses interfacing a DAC0808 converter to a PIC microcontroller and sensing light intensity with an LDR light sensor. Finally, it describes interfacing the LM75 temperature sensor to a PIC, including the sensor's register structure and digital output representation of temperature readings.
Vikas Kumar has experience in designing and implementing various digital and analog circuits including a 32-bit RISC CPU using Verilog, an integrated round robin arbiter on an FPGA board, asynchronous and synchronous FIFOs for clock domain crossing, a two-stage op-amp using UMC 180nm technology, and a bandgap reference circuit. He has worked as an intern at KeenHeads Technologies and IISc Bangalore developing projects related to analog design, layout design, and an embedded security system. Vikas has skills in RTL coding, digital and analog design, layout design, Verilog, C/C++, MATLAB, and uses tools including Xilinx Vivado, Cad
This presentation discusses the details of the I2C protocol and interfacing of EEPROM with 8051 based on I2C protocol. It also discusses the other applications of I2C protocol
This document describes a voice-based alert system for blind people that uses UV sensors to detect obstacles. The system includes a Cortex M3 microcontroller, IR sensors, a voice circuit, and buzzer. It aims to provide low-cost, low-power obstacle detection and voice alerts to guide blind users. The proposed model improves on previous versions by using a more advanced microcontroller and additional sensors like motion sensors. Potential applications include security systems, interactive exhibits, parking assistance, and robot navigation.
1) The document describes the architecture and features of the XC9500 CPLD, which consists of multiple Function Blocks and I/O Blocks interconnected by a FastCONNECT switch matrix.
2) Each Function Block provides programmable logic with 36 inputs and 18 outputs, and contains 18 independent macrocells that can each implement combinatorial or registered logic functions.
3) The I/O Block interfaces between internal logic and user I/O pins, and contains input/output buffers and output enable selection multiplexers.
Embedded C programming based on 8051 microcontrollerGaurav Verma
This lecture note covers the embedded 'c' programming constructs based on 8051 microcontroller. Although the same concepts can be used for other advanced microcontrollers with some modifications.
The document provides an overview of the ARM architecture, including:
- ARM was founded in 1990 and licenses its processor core intellectual property to design partners.
- The ARM instruction set includes 32-bit ARM and 16-bit Thumb instructions. ARM supports different processor modes like user mode, IRQ mode, and FIQ mode.
- Popular ARM processors include ARM7 and Cortex-M series. ARM licenses its IP to semiconductor companies who integrate the cores into various end products.
Low power VLSI design has become an important discipline due to increasing device densities, operating frequencies, and proliferation of portable electronics. Power dissipation, which was previously neglected, is now a primary design constraint. There are several sources of power dissipation in CMOS circuits, including switching power due to charging and discharging capacitances, short-circuit power during signal transitions, and leakage power from subthreshold and gate leakage currents. Designers have some control over power consumption by optimizing factors such as activity levels, clock frequency, supply voltage, transistor sizing and architecture.
Task and Function is the basic component of a programming language. Even on hardware Verification , those task and function is used. Task ans function provides a short way to repeatedly use the same block of code many times, This presentation gives you the basic information about Task and Function in Verilog. For more information on this, kindly contact us.
This document provides an introduction to PIC microcontrollers. It discusses the architecture of PIC microcontrollers, including the 16C6x and 16C7x architectures. It describes the registers, memory, and instruction set of PIC microcontrollers. Some key points covered include the Harvard architecture, pipelining, addressing modes, arithmetic, logical, and conditional instructions. Peripherals like timers and interrupts are also mentioned.
Fan in and Fan out related to vlsi design basic circuit concepts. This will be used for IC design process. By using such key methods, the performance of the circuit in IC will be improved in a better manner.
The document discusses FPGA design flow and programming. It describes the roles of the systems architect who defines high-level requirements and provides a golden model and test vectors. The FPGA designer is responsible for delivering a firmware that approximates the golden model on a hardware platform using vendor tools. The design flow includes simulation, synthesis, placement and routing, and testing at different stages to verify functionality and timing.
This Presentation describes the ARM CORTEX M3 core processor with the details of the core peripherals. Soon a CORTEX base controller(STM32F100RBT6) ppt will be uploaded. For more information mail me at:[email protected].
Module 2 ARM CORTEX M3 Instruction Set and ProgrammingAmogha Bandrikalli
This document provides an overview of the ARM Cortex M3 instruction sets and assembly programming. It begins by explaining why assembly is commonly used, including the need for detailed control flow and efficiency. The outline presented covers assembly basics, instructions, useful instructions, and assembly and C language programming. It then discusses the various instruction sets of the Cortex M3 with examples. Specific instructions covered include data processing, branch, load/store, and 32-bit instructions. It also notes instructions not supported by the Cortex M3 such as coprocessor, state change, and hint instructions.
The document discusses System on Chips (SoCs). It begins by outlining Moore's Law and how IC technology has scaled over time. This has enabled more system components to be integrated onto a single chip to create SoCs. The document then discusses trends in IC technology like technology scaling, system-on-a-chip, embedded systems, and time-to-market pressures. It provides examples of SoC applications and describes the SoC design process involving hardware-software co-design and reuse of intellectual property cores. In conclusion, the document defines an SoC as an integrated circuit that implements most or all functions of an electronic system on a single chip.
This document discusses printed circuit board (PCB) design. It begins with an introduction to PCBs, describing how they mechanically support and electrically connect electronic components using conductive tracks on insulating substrates. It then discusses the basic materials that make up PCBs like copper foil and plating. The document outlines the main fabrication steps for PCBs which include setting up, imaging, etching, drilling, masking, and electrical testing. It also describes the characteristics of through-hole and surface mount technology. The etching and assembly processes are explained in more detail. Finally, the document provides an overview of PCB design and routing software like EAGLE and includes an example of a power supply board.
UNIT I- CPLD & FPGA ARCHITECTURE & APPLICATIONSDr.YNM
Dr. Y.Narasimha Murthy Ph.D introduces programmable logic devices and their evolution from PLDs to CPLDs and FPGAs. The document discusses the basic architecture and applications of ROM, RAM, PLDs including PLA, PAL and GAL. It provides details on the programmable AND and OR planes in a PLA and compares device types based on their AND and OR array programmability. SPLDs, CPLDs and FPGAs are the main types of PLDs discussed.
Join this video course on udemy . Click here :
https://www.udemy.com/microcontroller-programming-stm32-timers-pwm-can-bus-protocol/?couponCode=SLIDESHARE
learn STM32 TIMERS, CAN,RTC, PWM,LOW POWER embedded systems and program them using STM32 Device HAL APIs STEP by STEP
>>Welcome to the course which teaches you advanced Micro-controller programming. In this course you are going to learn and master TIMERS, PWM, CAN, RTC, LOW POWER MODES of STM32F4x Micro-controller with step by step guidance. Highly recommended if you are seeking a career in the domain of Embedded software. <<
In this course, you will understand behind the scene working of peripherals with supportive code exercises. I have included various real-time exercises which help you to master every peripheral covered in this course and this course thoroughly covers both theory and practical aspects of TIMERS, PWM, CAN, RTC, LOW POWER MODES of STM32F4x Micro-controller.
FPGAs can be programmed after manufacturing to implement custom logic functions. They contain programmable logic blocks and interconnects that can be configured to create custom circuits. FPGAs provide flexibility compared to ASICs but have higher per-unit costs. The FPGA architecture consists of configurable logic blocks, programmable interconnects, and I/O blocks. Configurable logic blocks contain LUTs that implement logic functions. Programmable interconnects connect the logic blocks, and I/O blocks interface with external components. FPGAs are commonly used for prototyping, emulation, parallel computing, and other applications that require customizable hardware.
Flash Bootloader Solutions For ECU Re-Programming: Embitel is expertise in providing solutions and services for Flash bootloader development and ECU re-programming in automotive industry.
This document discusses interfacing digital-to-analog converters (DACs) and sensors with PIC microcontrollers. It introduces DACs and common DAC types like R-2R ladder and weighted resistor DACs. It then discusses interfacing a DAC0808 converter to a PIC microcontroller and sensing light intensity with an LDR light sensor. Finally, it describes interfacing the LM75 temperature sensor to a PIC, including the sensor's register structure and digital output representation of temperature readings.
Vikas Kumar has experience in designing and implementing various digital and analog circuits including a 32-bit RISC CPU using Verilog, an integrated round robin arbiter on an FPGA board, asynchronous and synchronous FIFOs for clock domain crossing, a two-stage op-amp using UMC 180nm technology, and a bandgap reference circuit. He has worked as an intern at KeenHeads Technologies and IISc Bangalore developing projects related to analog design, layout design, and an embedded security system. Vikas has skills in RTL coding, digital and analog design, layout design, Verilog, C/C++, MATLAB, and uses tools including Xilinx Vivado, Cad
This presentation discusses the details of the I2C protocol and interfacing of EEPROM with 8051 based on I2C protocol. It also discusses the other applications of I2C protocol
This document describes a voice-based alert system for blind people that uses UV sensors to detect obstacles. The system includes a Cortex M3 microcontroller, IR sensors, a voice circuit, and buzzer. It aims to provide low-cost, low-power obstacle detection and voice alerts to guide blind users. The proposed model improves on previous versions by using a more advanced microcontroller and additional sensors like motion sensors. Potential applications include security systems, interactive exhibits, parking assistance, and robot navigation.
1) The document describes the architecture and features of the XC9500 CPLD, which consists of multiple Function Blocks and I/O Blocks interconnected by a FastCONNECT switch matrix.
2) Each Function Block provides programmable logic with 36 inputs and 18 outputs, and contains 18 independent macrocells that can each implement combinatorial or registered logic functions.
3) The I/O Block interfaces between internal logic and user I/O pins, and contains input/output buffers and output enable selection multiplexers.
Embedded C programming based on 8051 microcontrollerGaurav Verma
This lecture note covers the embedded 'c' programming constructs based on 8051 microcontroller. Although the same concepts can be used for other advanced microcontrollers with some modifications.
Programming The Arm Microprocessor For Embedded Systemsjoshparrish13
This document provides an outline for a training course on programming the ARM microprocessor for embedded systems. The outline covers topics such as ARM technology overview, ARM tools and products, the ARM processor, instruction sets, exceptions and interrupts, firmware, caches, and memory management. The goal is to help students develop an understanding of ARM processor execution needed to develop and debug embedded software with or without an operating system.
This document provides an overview of using STM32 microcontrollers and the ARM Cortex-M architecture. It discusses the different Cortex cores from ARM, then focuses on the Cortex-M family. It introduces the STM32F4 chip and resources for documentation. It explains concepts like memory mapping, peripherals, GPIO configuration, and provides an example of configuring USART communication. The document also mentions CMSIS for hardware abstraction and the FreeRTOS real-time operating system.
The document provides an overview of the STM32 MCU family from STMicroelectronics. It discusses the key features such as an ARM Cortex-M3 core, Flash memory up to 512KB, SRAM up to 64KB, low power modes, timers, and communication peripherals. It also outlines the applications for industrial equipment, appliances, low power devices, and consumer electronics. Finally, it gives a high-level description of the system architecture and various peripherals including DMA, ADC, DAC, communication interfaces, and watchdogs.
This document provides an overview of an introduction to STM32 course. The course covers the ARM Cortex processor, STM32 system on chip, STM32 building blocks, low power operation, safety features, the flash module, and development tools. The goal of the course is to help students understand what the ARM Cortex processor and STM32 SoC are, and identify the main components of the STM32 microcontroller.
This presentation summarizes the key aspects of a Phase Locked Loop (PLL) circuit. It was presented by Aman Jain, Gourav Gupta, Mohit Swarnkar, Narendra Singh Rajput, and Piyush Pal to Ravitesh Mishra. The presentation outlines what a PLL is, the main components of a PLL including the phase detector, filter, and voltage controlled oscillator. It also discusses the locked condition of a PLL, the dynamics and transient response of PLL circuits, and applications of PLLs such as frequency multiplication, jitter reduction, and clock recovery.
The document discusses phase locked loops (PLLs). It provides an outline that covers synchronization, PLL basics, analog PLLs, digital PLLs, and FPGA implementation. It describes how PLLs work, tracking the average phase and frequency of an input reference signal. The key components of an analog PLL are identified as a voltage controlled oscillator (VCO), phase detector (PD), and loop filter. A brief history of PLL development is also presented.
Généralités sur les périphériques du STM32Hajer Dahech
Lien Téléchargement pptx https://hajereducation.tn/peripheriques-stm32-simple-resume-presentation-powerpoint/
Généralités sur les périphériques du STM32
Merci , Thanks For watching Video
=====Subscribe == S'abonner
Playlist :STM32 :vidéos+Files+Code
The document describes an experiment to interface an LED and switch with an STM32 microcontroller, where the LED is controlled by the switch using the STM32. It discusses the components used, including the STM32 microcontroller, LED, button, resistors, and programming tools. The procedure involves designing the circuit in Proteus, writing code in STM32CubeMX to control the LED based on the button state, and simulating the circuit behavior.
We are one of the best embedded systems training institute for advance courses. We are the pioneer of the embedded system training in Pune & Pcmc with the expertise of over 16 years. we are working in the field training & development of embedded systems & currently we are also working on live projects as per the requirements of clients. though we provide many different courses & training in embedded all aim at giving good practical knowledge to students as well help them in their career.
We are one of the best embedded systems training institute for advance courses. We are the pioneer of the embedded system training in Pune & Pcmc with the expertise of over 16 years. we are working in the field training & development of embedded systems & currently we are also working on live projects as per the requirements of clients. though we provide many different courses & training in embedded all aim at giving good practical knowledge to students as well help them in their career.
STONE Tech is a manufacturer of HMI display modules (Intelligent TFT LCD). We provide LCD modules/LCD Displays, Graphic LCM, smart Display LCD, TFT LCM, Custom LCD Module Display, and LCD panels. china LCD Manufacturers.
The document discusses microcontrollers and the PIC16F877 microcontroller in particular. It provides the following key points:
- A microcontroller is a single-chip computer containing a processor, memory, and input/output peripherals. Microcontrollers can store and run user-written programs.
- The main parts of a microcontroller include a CPU, RAM, ROM, I/O lines, timers, and analog-to-digital and digital-to-analog converters.
- The PIC16F877 is chosen for its low cost, reliability, ease of use, and ability to perform a wide range of tasks using C language software.
Rodrigo Almeida - Microkernel development from project to implementationFelipe Prado
This document discusses developing a microkernel from project to implementation. It covers topics like kernel components, designing a kernel project, concepts for developing a microkernel like function pointers and structs, building a device driver controller, and using callbacks. Code examples are provided for initializing hardware and communicating with an LCD. The goal is for participants to have a better understanding of kernels, their advantages, and restrictions.
Implementation of sign board dot matrix display with 8051Aminu Bugaje
This document describes a lab experiment to implement a sign board using an 8x8 dot matrix LED display controlled by an 8051 microcontroller. The objectives are to design the hardware interface between the display and microcontroller, develop the software using C language, and simulate and verify the program. An 8x8 dot matrix LED, 74HC595 shift register, and 8051 microcontroller are used in the hardware design to drive the display using few I/O pins. The C code controls the shift register to display characters, numbers, and a scrolling clock on the LED matrix. The hardware and software designs are simulated and the objectives are achieved, though only one LED matrix was used due to time and cost constraints.
Itsp documentation quadcopter flight controller based on kalman filtersJyotirmaya Mahanta
The document provides documentation for a quadcopter flight controller project using an Arduino Due and Kalman filters. It describes the author's process of setting up the Arduino Due in Atmel Studio instead of the Arduino IDE to better understand register settings. It details how to initialize various functions needed for the project, including uploading code, declaring pins, timers, I2C communication, UART, and interrupts. The author worked through issues with i2c communication and resetting, and provided code samples for initializing each required function.
Instructions 3-5 pages double space research paper about Eric Sc.docxnormanibarber20063
Instructions
3-5 pages double space research paper about Eric Schmidt (Google)
High profile manager CEOs. Please include information about this person’s personal and professional background, management style and skills and research about why this person is (or is not) such an effective manager/leader. You should utilize at least three articles dated from 2008 to present as references.
Paper should contain the following:
· Title page
· An introduction3-5 pages (double-spaced, no more than 12 pt. font) of cited research in APA format.
· A conclusion
· Reference page in APA format (Including at least three articles on management dated from 2008 to present)
Paper should include three sections: the Title Page, Main Body, and References. An Abstract in not necessary for this paper.
EECE237/ATT00001.htm
__MACOSX/EECE237/._ATT00001.htm
EECE237/ATT00002.htm
__MACOSX/EECE237/._ATT00002.htm
EECE237/ATT00003.htm
__MACOSX/EECE237/._ATT00003.htm
EECE237/ATT00004.htm
__MACOSX/EECE237/._ATT00004.htm
EECE237/ATT00005.htm
__MACOSX/EECE237/._ATT00005.htm
EECE237/Lab 01 Notes.pdf
EECE 237 Lab 01 Setup Notes
Fall Semester 2016
I. Communicate with the Launchpad by PuTTY in your PC.
From Computer Management of your Microsoft Windows, check which COM port is
connected with your Launchpad.
For example, the following case (a PC running Windows 10) shows it is COM3.
Open PuTTY, choose “serial” for the connection mode. Set the “Serial Line” to the port you
are using, and set the “Speed” to 115200.
II. Tiva Software (TivaWare for C series)
http://www.ti.com/tool/sw-tm4c
Install “SW-TM4C-2.1.3.156”. The Keil RealView MDK is now ARMKeil MDK. If the installed
TivaWare locates in C:\ti, the example “Hello” project is in “C:\ti\TivaWare_C_Series-
2.1.3.156\examples\boards\ek-tm4c123gxl”.
http://www.ti.com/tool/sw-tm4c
__MACOSX/EECE237/._Lab 01 Notes.pdf
EECE237/Lab Preparation Notes.pdf
EECE 237 Lab 01 Preparation Notes
Fall Semester 2016
I. Install Keil Toolchain on your PC
The following steps describe installation of ARM Keil toolchain, the MDK ARM (MDK is the
abbreviation of Microcontroller Development Kit). It is highly recommended that you have access to a
PC or a laptop running Windows 7, 8, or 10. The functioning of the toolchain is not tested in Mac or
Linux boxes. Screenshots were captured from an installation in a Windows 10 PC.
1. Fill out the form at
https://www.keil.com/demo/eval/armv4.htm
Notice that we use version 4.74. Set your Company to California State University, Chico. Set your
device to TM4C123. It should not cost any money. You can select or not select whether you
want email from ARMKeil.
Submit the form after you finish it.
2. You will see a download link similar to the following:
Download the software MDK474.EXE.
3. Run the MDK474.EXE file. Install the application in some place that is easy to find, for example
C:\Keil or D:\Keil.
https://www.keil.com/de.
Computer Programming and MCUs Assembly Language STM32Cu.pdfableelectronics
Computer Programming and MCUs:
- Assembly Language
- STM32CubeIDE
- STM32F3DISCOVERY Board MCU
Objectives:
1. Create a function that can chase an LED around the LED circle. This means that only one LED
should be on, and the currently on LED will move either clockwise, or anti-clockwise around the
circle of LEDs. Provide a value to the function in R1 which selects whether the LED goes
clockwise or anti-clockwise. Provide a value to the function in R2 which selects how many LEDs
should be on at the same time (1 LED chasing, 2 LEDs chasing, etc).
2. Make a map between an ASCII character and a pattern of LEDs being on/off. Demonstrate this
with a function that uses an ASCII value stored in R1 to turn the LEDs on/off to show the pattern.
3. Use the discovery board user input button to step through the characters in an ASCII string and
show the LED patterns one at a time.
General Assumptions/hints:
- User Button located in GPIO port A (base address: 0x48000000)
- LEDs located in GPIO port E (base address: 0x48001000)
- LED circle located in GPIO port E, bits 8-15
- Use STM32F3-Reference-Manual-Large.pdf for register addresses/offsets
Basic steps:
1. Enable the clock for each I/O port we want to use
2. Setup GPIO Registers (Button = input, LEDs = output)
3. Read from input or write from output
STM32F3DISCOVERY Board MCU:
STM32CubeIDE:
P. Project Explorer x Thern arn no projects in ynur workspaca. To add a project: Create a mew
Makefile project in a directory centaining revisting cade Create a new C or Ct+ prodect Crate a
Naw STM37 prolact Craata a Naw StM37 Proinct fram an Fristing Create a project... timpert
projects... D itams selected.
This document describes an energy saving visitor counter project that uses a microcontroller and infrared sensors. The objective is to design a circuit that can count the number of people entering and exiting a room and control the room light accordingly. It uses an IR transmitter and receiver to detect movement and increments or decrements the counter value, which is displayed on seven-segment displays. The microcontroller controls the counting and display functionality while receiving input from the IR sensors. Proteus and Keil software are used to simulate and program the microcontroller respectively.
1. The document discusses embedded systems and Microchip PIC microcontrollers. It describes what embedded systems are and provides examples of application areas.
2. It explains the differences between microprocessors and microcontrollers, and discusses the architecture and features of Microchip's PIC microcontrollers.
3. The document provides an overview of programming PIC microcontrollers, including the instruction set, device structure, and basic circuit requirements.
First Steps Developing Embedded Applications using Heterogeneous Multi-core P...Toradex
Read our blog for the latest on demystifying the development of embedded systems using Heterogeneous Multicore Processing architecture powered SoCs! This might provide you with the jump start you need for your development. https://www.toradex.com/blog/first-steps-developing-embedded-applications-using-heterogeneous-multicore-processors
15LLP108_Demo4_LedBlinking.pdf1. Introduction In D.docxfelicidaddinwoodie
15LLP108_Demo4_LedBlinking.pdf
1. Introduction
In Demo3, we have learned how to read sensor values of light, temperature and humidity of a node
and output these values to the console. In this demonstration, we will use the code from Demo3 and
learn how to turn on/off the LEDs and make them blinking regularly on the sensor node XM1000,
meanwhile to count how many times the LED has blinked and output the count to the console.
2. Timer
In order to make the blue LED on the XM1000 sensor node to blink in every half second (i.e. On 0.5S
and Off 0.5S), we also need a timer. Follow the instructions in Demo3 for configure and reset a timer.
We aslo need to create an infinite while() loop so that it runs our functions repeatedly, such as
counting the times the LED has blinked, output the counter’s value and actually turn on or off the
LEDs to make it blinking.
Please follow timer and while() loop structure in Demo3.
3. LED Blinking
To get access to the LED functionalities in Contiki, we need to include the LED header file in the
source code:
#include "leds.h" // file is in directory /home/user/contiki/core/dev
After the process begin, we have to initialise the LEDs on the sensor node by calling the following
function:
leds_init(); // Initialise the LEDs
And finally we can turn on, off, or blink the LEDs by the following functions:
void leds_on(unsigned char leds);
void leds_off(unsigned char leds);
void leds_toggle(unsigned char leds);
void leds_invert(unsigned char leds);
For example, if you want to blink the Blue LED, yon need to call the toggle function as:
void leds_toggle(LEDS_BLUE); // Toggle the blue LED
4. Exercise
Modify the program from Demo3 with periodic timer to make the BLUE led blinking in every half
second, also to count the blinking times and output the counted number to the console.
Can your change the code so that the BLUE LED is lighted for 1 second and off for 0.5 second
periodically?
15LLP108 – Internet of Things and Applications
Lab Session 2: Demo 4 – LED Blinking
Prepared by Xiyu Shi
5. Source code
Here is the source code for reference
#include "contiki.h"
#include "leds.h"
#include <stdio.h> /* for printf() */
static struct etimer timer;
/*____________________________________________________*/
PROCESS(led_blinking_process, "LED Blinking Process");
PROCESS(LED_process, "LED process");
AUTOSTART_PROCESSES(&LED_process);
/*____________________________________________________*/
PROCESS_THREAD(LED_process, ev, data)
{
static int count = 0;
PROCESS_BEGIN();
etimer_set(&timer, CLOCK_CONF_SECOND/2); // 0.5S timer
leds_init(); // intialise the LEDs
while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev==PROCESS_EVENT_TIMER); // wait for timer event
count++; // count the blinking times
process_start(&led_blinking_process, NULL); // to blink the BLUE Led
printf("Count: %d\n", count); // output the counte ...
The document discusses Real Time Operating Systems (RTOS). It defines RTOS as a multitasking operating system intended for real-time applications. RTOS provides deterministic timing behavior and limited resource utilization for applications that require logically correct results within strict deadlines, such as those found in automotive and industrial systems. The document outlines some key RTOS concepts like multitasking, interrupt handling, and memory management. It explains that while not necessary for simple embedded systems, RTOS is beneficial for more complex real-time applications as it helps manage hardware resources and schedule tasks to meet application demands and deadlines.
The document introduces how to create a basic "Hello World" project in MPLAB IDE using a PIC32 microcontroller. It describes setting up a new project, creating a source code file, adding code for digital output pins on ports A and B, compiling and running the code in the simulator. The code turns on LEDs connected to the ports by setting the pins as outputs and writing a 1 to the ports.
Powersim's SimCoder can automatically generate code from control schematics for TI F2803x DSPs. The tutorial describes using an example buck converter circuit to generate code in PSIM, compile it in CodeComposerStudio, run it on hardware, and monitor signals using PSIM's DSP Oscilloscope. Key steps include setting SimCoder parameters, defining target elements, generating code, importing projects into CCS, loading/running code on hardware, and viewing waveforms.
The main aim of this project is to avoid the accident and death in the gas leakage explosion in house, hotels and industries. Domestically we use natural gas and it is very useful for burning purpose. If this gas is leaked in our kitchens, hotels or factories and not sensed in time, it may lead to fatal disaster, and may cause human and material loss. For this purpose we have developed “GAS LEAKAGE DETECTION SYSTEM”.
Advanced View of Atmega Microcontroller Projects List - ATMega32 AVR.pdfWiseNaeem
Most of the electronics geeks are asking the whole list of Atmega AVR projects PDF here we will share list every month as our projects are being updated on daily basis.
Rearchitecturing a 9-year-old legacy Laravel application.pdfTakumi Amitani
An initiative to re-architect a Laravel legacy application that had been running for 9 years using the following approaches, with the goal of improving the system’s modifiability:
・Event Storming
・Use Case Driven Object Modeling
・Domain Driven Design
・Modular Monolith
・Clean Architecture
This slide was used in PHPxTKY June 2025.
https://phpxtky.connpass.com/event/352685/
The development of smart cities holds immense significance in shaping a nation's urban fabric and effectively addressing urban challenges that profoundly impact the economy. Among these challenges, road accidents pose a significant obstacle to urban progress, affecting lives, supply chain efficiency, and socioeconomic well-being. To address this issue effectively, accurate forecasting of road accidents is crucial for policy formulation and enhancing safety measures. Time series forecasting of road accidents provides invaluable insights for devising strategies, enabling swift actions in the short term to reduce accident rates, and informing well-informed road design and safety management policies for the long term, including the implementation of flyovers, and the enhancement of road quality to withstand all weather conditions. Deep Learning's exceptional pattern recognition capabilities have made it a favored approach for accident forecasting. The study comprehensively evaluates deep learning models, such as RNN, LSTM, CNN+LSTM, GRU, Transformer, and MLP, using a ten-year dataset from the esteemed Smart Road Accident Database in Hubballi-Dharwad. The findings unequivocally underscore LSTM's superiority, exhibiting lower errors in both yearly (RMSE: 0.291, MAE: 0.271, MAPE: 6.674%) and monthly (RMSE: 0.186, MAE: 0.176, MAPE: 5.850%) variations. Based on these compelling findings, the study provides strategic recommendations to urban development authorities, emphasizing comprehensive policy frameworks encompassing short-term and long-term measures to reduce accident rates alongside meticulous safety measures and infrastructure planning. By leveraging insights from deep learning models, urban development authorities can adeptly shape the urban landscape, fostering safer environments and contributing to global safety and prosperity.
This study will provide the audience with an understanding of the capabilities of soft tools such as Artificial Neural Networks (ANN), Support Vector Regression (SVR), Model Trees (MT), and Multi-Gene Genetic Programming (MGGP) as a statistical downscaling tool. Many projects are underway around the world to downscale the data from Global Climate Models (GCM). The majority of the statistical tools have a lengthy downscaling pipeline to follow. To improve its accuracy, the GCM data is re-gridded according to the grid points of the observed data, standardized, and, sometimes, bias-removal is required. The current work suggests that future precipitation can be predicted by using precipitation data from the nearest four grid points as input to soft tools and observed precipitation as output. This research aims to estimate precipitation trends in the near future (2021-2050), using 5 GCMs, for Pune, in the state of Maharashtra, India. The findings indicate that each one of the soft tools can model the precipitation with excellent accuracy as compared to the traditional method of Distribution Based Scaling (DBS). The results show that ANN models appear to give the best results, followed by MT, then MGGP, and finally SVR. This work is one of a kind in that it provides insights into the changing monsoon season in Pune. The anticipated average precipitation levels depict a rise of 300–500% in January, along with increases of 200-300% in February and March, and a 100-150% increase for April and December. In contrast, rainfall appears to be decreasing by 20-30% between June and September.
A SEW-EURODRIVE brake repair kit is needed for maintenance and repair of specific SEW-EURODRIVE brake models, like the BE series. It includes all necessary parts for preventative maintenance and repairs. This ensures proper brake functionality and extends the lifespan of the brake system
Civil engineering faces significant challenges from expansive soils, which can lead to structural damage. This study aims to optimize subtractive clustering and Fuzzy C-Mean Clustering (FCM) models for the most accurate prediction of swelling percentage in expansive soils. Two ANFIS models were developed, namely the FIS1S model using subtractive clustering and the FIS2S model utilizing the FCM algorithm. Due to the MATLAB graphical user interface's limitation on the number of membership functions, the coding approach was employed to develop the ANFIS models for optimal prediction accuracy and problem-solving time. So, two programs were created to determine the optimal influence radius for the FIS1S model and the number of membership functions for the FIS2S model to achieve the highest prediction accuracy. The ANFIS models have demonstrated their highest predictive ability in predicting swelling percentage, thanks to the optimization of membership functions and cluster centers. The developed programs also showed excellent performance and can be potentially applied to optimize subtractive clustering and FCM models in accurately modeling various engineering aspects.
Third Review PPT that consists of the project d etails like abstract.Sowndarya6
CyberShieldX is an AI-driven cybersecurity SaaS web application designed to provide automated security analysis and proactive threat mitigation for business websites. As cyber threats continue to evolve, traditional security tools like OpenVAS and Nessus require manual configurations and lack real-time automation. CyberShieldX addresses these limitations by integrating AI-powered vulnerability assessment, intrusion detection, and security maintenance services. Users can analyze their websites by simply submitting a URL, after which CyberShieldX conducts an in-depth vulnerability scan using advanced security tools such as OpenVAS, Nessus, and Metasploit. The system then generates a detailed report highlighting security risks, potential exploits, and recommended fixes. Premium users receive continuous security monitoring, automatic patching, and expert assistance to fortify their digital infrastructure against emerging threats. Built on a robust cloud infrastructure using AWS, Docker, and Kubernetes, CyberShieldX ensures scalability, high availability, and efficient security enforcement. Its AI-driven approach enhances detection accuracy, minimizes false positives, and provides real-time security insights. This project will cover the system's architecture, implementation, and its advantages over existing security solutions, demonstrating how CyberShieldX revolutionizes cybersecurity by offering businesses a smarter, automated, and proactive defense mechanism against ever-evolving cyber threats.
International Journal of Advance Robotics & Expert Systems (JARES)jaresjournal868
Call For Papers!!!
International Journal of Advance Robotics & Expert Systems (JARES)
Web page Link: http://airccse.com/jares/index.html
Submission Deadline :June17, 2025
submission Link: http://airccse.com/submission/home.html
Contact Us : [email protected] or [email protected] or [email protected]
Impurities of Water and their Significance.pptxdhanashree78
Impart Taste, Odour, Colour, and Turbidity to water.
Presence of organic matter or industrial wastes or microorganisms (algae) imparts taste and odour to water.
Presence of suspended and colloidal matter imparts turbidity to water.
En esta presentación se encuentra la explicación sobre la tomografía Axial Computarizada, se habla sobre su historia, partes, operación general y especifica del equipo, tipos de densidades y sus aplicaciones más comunes y las innovadoras.
This document provides information about the Fifth edition of the magazine "Sthapatya" published by the Association of Civil Engineers (Practicing) Aurangabad. It includes messages from current and past presidents of ACEP, memories and photos from past ACEP events, information on life time achievement awards given by ACEP, and a technical article on concrete maintenance, repairs and strengthening. The document highlights activities of ACEP and provides a technical educational article for members.
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...gerogepatton
The International Journal of Artificial Intelligence & Applications (IJAIA) is a bi monthly open access peer-reviewed journal that publishes articles which contribute new results in all areas of the Artificial Intelligence & Applications (IJAIA). It is an international journal intended for professionals and researchers in all fields of AI for researchers, programmers, and software and hardware manufacturers. The journal also aims to publish new attempts in the form of special issues on emerging areas in Artificial Intelligence and applications.
May 2025 - Top 10 Read Articles in Artificial Intelligence and Applications (...gerogepatton
Programming the ARM CORTEX M3 based STM32F100RBT6 Value Line Discovery Board
1. STM32F100RB (ARM Cortex core) Programming Tutorial
Introduction
STM32VLDISCOVERY evaluation board
STM32 Value-line discovery board is a low-cost evaluation board for Value-line of STM32
microcontrollers from STMicroelectronics. Value line of STM32 microcontrollers are low cost
version of higher devices. It can run on 24MHz and don’t have some of peripherals available on
higher devices. On this board is soldered 64-pin value-line STM32 (with ARM Cortex-M3 core)
microcontroller and ST-Link debugger, so board is complete hardware needed to run programs
for STM32 devices! You only need USB cable for connection board to PC.
Of course, we need build some external hardware because on the STM32LVDISCOVERY are
mounted only two LEDs and two pushbuttons - one for RESET and one for user application
purposes. Discovery board has two long rows of pin headers and one short (between them) with
all important signals from microcontroller and power supply voltages. Due to this short
connector STM32VLDISCOVERY board cannot be placed on typical solder less board.
This tutorial shows you how to write applications for STM32 devices without use STM32
StdPeriph Library. This library in my opinion isn't best solution for writing apps for STM32 and
I show you that writing apps without this library is easy and fun. Although this tutorial is based
on STM32 Value Line micros and STM32VLDISCOVERY board in most cases can be also used
for other STM32F1 (mainstream) devices and other development boards.
2. Lesson 1 - First program. Blinking LED
For writing applications for STM32VLDISCOVERY board we need toolchain, which supports
STLink debugger and SWD protocol. Unfortunately at this moment OpenOCD debug tool do not
support SWD and STLink, so we can't use free tool chains. SWD protocol supports following
tool chains: MDK-ARM from Keil, EWARM from IAR and TrueSTUDIO form Atollic. In this
tutorial all examples will be shown for MDK-ARM.
Creating uVision project - step by step
To create new uVision project select "New uVision Project" command from menu "Project":
You will be asked for name and disk location for created project. Next, you must select device.
On STM32VLDISCOVERY board is installed STM32F100RBT6 device, so select
"STM32F100RB" option from dialog window:
3. After device selection uVision ask if add startup file to project tree:
If you click "Yes", in project tree will be present startup file, suitable for STM32F100RB
microcontroller:
After creating project, we can write application code. For this we must create a new C source
file. From "File" menu select "New" command:
4. After this will be created a new text file:
Now, let save this file as main.c:
5. And add it to project tree:
and pick main.c file from disk. File main.c should be in SourceGroup1:
6. We are ready to writing application source code. Let us write in main.c file following lines:
#include "stm32f10x.h"
int main(void)
{
do{
}while(1);
}
Save the file and select command "Build target" from "Project" menu. In the "Build output"
window will be written following messages:
Build target 'Target 1'
assembling startup_stm32f10x_md_vl.s...
compiling main.c...
C:KeilARMINCSTSTM32F10xstm32f10x.h(80): error: #35: #error directive: "Please select
first the target STM32F10x device used in your application (in stm32f10x.h file)"
Target not created
Note: We must defined, which type of STM32 microcontroller are used. So, go to the project
tree and click right mouse button on "Target1" folder icon, and select "Options for Target..."
command from context menu:
7. Next, go to "C/C++" tab and write in "Define" edit box "STM32F10X_MD_VL" string:
8. After this try build application again. Still errors occur in build output window :
Build target 'Target 1'
assembling startup_stm32f10x_md_vl.s...
compiling main.c...
C:main.c(7): warning: #1-D: last line of file ends without a newline
linking...
a.axf: Error: L6218E: Undefined symbol SystemInit (referred from startup_stm32f10x_md_vl.o).
Target not created
Note: In this case this is a linker error, that can't find symbol SystemInit. As we see, call for this
symbol came from startup file and this is call for SystemInit function. We can go for a few ways:
remove call for this function or write this function (may it be an empty function) or use function
supplied by STMicro in their device support for CMSIS library. We took last way, and use
stm32f10x_system.c file. We need to download STM32 StdPeriph library for STM32F10x
devices. In archive with this library is a folder "CMSIS", which we need to extract from the
archive. We need only the CMSIS folder. The STM32F10x_StdPeriph_Driver folder can be
deleted ;-).
Go to CMSISCM3DeviceSupportSTSTM32F10x subfolder, copy *.c and *.h files to folder
with your uVision project and add *.c files to the project tree.
9. Now, try to build project. In "Build output window should be written following text:
Build target 'Target 1'
assembling startup_stm32f10x_md_vl.s...
compiling main.c...
compiling system_stm32f10x.c...
linking...
Program Size: Code=808 RO-data=320 RW-data=20 ZI-data=1636
"prj1.axf" - 0 Error(s), 0 Warning(s).
SUCCES! We have first compiled application for STM32!
Let’s Blink LED
After successfully creating and compiling first empty project we can add some source code to
them. We want to blink LED LD4, which are connected to PC8 pin of STM32F100RBT6. So we
need to configure this pin as output. At this moment, You need to download from STMicro
website document called RM0041. In this Reference Manual are described all peripherals of
STM32F100 microcontrollers. Because this document has over 650 pages it impossible to copy
all informations to this website. So I will reference to this document and suitable chapters
concerning peripherals used in this tutorial. I will not reference to exact page, because after
updating document by ST Micro page numbers can be not actual. I will be referenced to sections,
figures and tables.
RCC configuration
Look at section 6 of RM0041, that concern about RCC (Reset and Clock Control) peripheral. In
section 6.2 Figure 8 shows clock tree on STM32F100 low and medium density microcontrollers.
Looks complicated, but almost all configurations are done by SystemInit function from
system_stm32f10x.c file. Clocks will be configured to obtain specified core speed. Remember
that - after reset all peripherals have disabled clock! So we need enable clock for every used
peripheral. Go to section 6.3.7 of Reference Manual. This section describes APB2ENR register
of RCC peripheral. This register is responsible for enabling clock signal for peripherals working
on APB2 bus. All GPIO peripherals works on APB2 bus, so this register are interesting for us.
Bits 2 to 8 are used to enable clock for each GPIO port (form GPIOA to GPIOG). We ned use
only GPIOC port, so we need set bit number 4 of APB2ENR register. How do it? Probably You
10. think about (1 << 4)? Right? That is wrong! Open document stm32f10x.h and search for bit
name - "IOPCEN". You should find some macro definitions, which one from them is:
#define RCC_APB2ENR_IOPCEN ((uint32_t)0x00000010) /*!< I/O port C clock enable */
What is it? It's a bitmask for IOPCEN bit! So we don't need bitwise shifting one by pin number,
we can use suitable bitmask! So, how will be looks first code line of us application? Probably
something like that:
#include "stm32f10x.h"
int main(void)
{
RCC_APB2ENR | = RCC_APB2ENR_IOPCEN;
do{
}while(1);
}
But this is wrong. After compiling application, compiler returns following error:
main.c(14): error: #20: identifier "RCC_APB2ENR" is undefined
Why? We use register name from Reference Manual, so why it is wrong? This is wrong, because
all peripherals are divided into structures that hold peripherals registers. These structures are
defined in stm32f10x.h file. So go to this file and search for "Peripheral_registers_structures"
string. You will see some of typedefs describing structures for all of peripherals. Each structure
holds all registers of peripheral. Naming scheme of peripheral structures are following:
PeriphName_TypeDef. So for RCC peripheral structure definitions with registers are
"RCC_TypeDef". So let's search for "RCC_TypeDef" string. We see, that registers name are
slightly different from names from Reference Manual. Names in structure are without part of
peripheral name. Register described in Reference Manual as RCC_APB2ENR in structure has
name APB2ENR. OK, now we need name of structure variable. So let search again for
RCC_TypeDef string. You should find following line:
#define RCC ((RCC_TypeDef *) RCC_BASE)
Now all are clear! In stm32f10x.h file is defined macro RCC that in fact are pointer dereference
to our RCC_TypeDef structure that resides at RCC_BASE address. If you search for
RCC_BASE string, you find another macro, that defines RCC_BASE as base address of RCC
peripheral in STM32F100 memory space. So now, we can use RCC macro as pointer to
11. structure, that holds all register of RCC peripheral. Now we can write correct code for set
IOPCEN bit in APB2ENR register of RCC peripheral:
#include "stm32f10x.h"
int main(void)
{
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
do{
}while(1);
}
Try to build application. Hooray! No errors! We have enabled clock for GPIOC peripheral and
we can configure GPIO for driving LED.
GPIO configuration
Now, go to Section 7 of RM0041. As you can read, each GPIO port has several registers to
configure and control input and output state of microcontroller pins. Most important information
for us is that each GPIO port has two 32-bit configuration registers: CRL and CRH. CRL register
is responsible for configuration of pins from 0 to 7 and CRH register is responsible for
configuration of pins form 8 to 15. So for each GPIO pin we have four configuration bits. Table
16 from RM0041 shows all possible configurations of GPIO pins. Because configuration
registers are slightly complicated, I prepared some macros for easier configuring GPIO ports on
STM32 microcontrollers. With this macros pin configuration are easy and clear to read. These
macros are in antilib_gpio.h file. Download this file, and save into folder with your application
project. Example configuration for PC8 pin that works as output looks like that:
GPIOC->CRH = (GPIOC->CRH & CONFMASKH(8)) | GPIOPINCONFH(8,
GPIOCONF(GPIO_MODE_OUTPUT2MHz, GPIO_CNF_OUTPUT_PUSHPULL));
Let me describe each element of this code line. GPIO->CRH mean of course access to
GPIOC_CRH register. We want change configuration only for PC8, so remaining bits of this
register should be unchanged. We realize that by reading contents of GPIO_CRH register and
clear bits responsible for PC8 configuration. Macro CONFMASKH (8) give bitmask for clearing
4 lowest bits: 0xFFFFFFF0. Clearing this 4 bits will be done by bitwise AND of register with
this bitmask. Next, we need to set configuration bits for PC8 suitable for driving LED. Output
12. should be work as push-pull output. And what is this megahertz? This specified slew rate on
outputs pin. For driving LED we don’t need fast edges of driving signals, so we use slowest slew
ratio for PC8.
Controlling output state of GPIO pins can be realized on two ways: by writing port value to ODR
(Output Data Register) register or by writing to BSRR (Bit Set/Reset Register) or BRR (Bit
Reset Register). Writing to ODR register modifies value of all pins of given GPIO port. Writing
to BSRR/BRR registers modifies state only this bits, that writing value has ones on bits position.
For example to set bit PC8 we can use following code:
GPIOC->BSRR = (1 << 8);
After execution of this line bit number 8 (and only this bit) of GPIOC will be set. Other bits
remain unchanged. Upper 16 bits of BSRR register can be used to clearing pin state:
GPIOC->BSRR = (1 << 24);
After execution of this line bit number 8 of GPIOC will be cleared. To resetting pin state we can
use BRR register too:
GPIOC->BRR = (1 << 8);
After execution of this line, bit number 8 will be cleared. If we want clear single bit using ODR
register, we must perform bitwise logical operations in Read-Modify-Write scheme:
GPIOC->ODR = GPIOC->ODR | (1 << 8);
but this operation is not atomic! After reading ODR state, his value can be changed (in interrupt
for example), and after write modified value we can lose this change. So better use atomic
operations with BSRR / BRR register.
Finally, let's blink the LED!
After getting all informations from above discussion, we can write our blinking LED application.
How to make a delay?
Simplest way to make a delay (let's call 'monkey delay') is loop counting some many times. Time
of this delay it's hard to define. Especially on ARM devices counting how CPU cycles loop will
be executed is difficult. Let's define variable named dly:
13. volatile uint32_t dly;
Short explain about two keywords before variable name. An 'volatile' keyword says to compiler
"Don't optimize access to this variable. Its value can change in any time of execution of
program". Second keyword defines size of variable - 32-bit unsigned integer. Now, let's do a
simple loop using this variable:
for(dly = 0; dly < 500000; dly++);
This code give us 500.000 loop cycles, that in effect give us some time of CPU spending in the
loop. Without keyword 'volatile' this code probably gives us no cycles and no time delay.
Complete code of blink LED application:
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 1. Blinking the LED.
// Copyright : Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
// e-mail : [email protected]
// Mobile No.: 9811506739
//=============================================================================
#include "stm32f10x.h"
#include "antilib_gpio.h"
//=============================================================================
// main function
//=============================================================================
int main(void)
{
volatile uint32_t dly;
RCC->APB2ENR |= RCC_APB2ENR_IOPCEN;
GPIOC->CRH = (GPIOC->CRH & CONFMASKH(8)) | GPIOPINCONFH(8,
GPIOCONF(GPIO_MODE_OUTPUT2MHz, GPIO_CNF_OUTPUT_PUSHPULL));
14. while (1)
{
for(dly = 0; dly < 500000; dly++);
GPIOC->BSRR = (1 << 8);
for(dly = 0; dly < 500000; dly++);
GPIOC->BRR = (1 << 8);
}
}
//=============================================================================
// End of file
//=============================================================================
How to make this code more universal? When LED diode will be connected to other pin, we
need modify in code all references to them. So let's use the preprocessor to define some macros
describing connected LED diode:
#define LED_BLUE_GPIO GPIOC
#define LED_BLUE_PIN 8
Now we can use defined macros in place to direct GPIO and pin number, but in case of configure
GPIO there is need to specify configuration register (low or high). We can do this like in
example:
#if (LED_BLUE_PIN > 7)
LED_BLUE_GPIO->CRH = (LED_BLUE_GPIO->CRH & CONFMASKH(LED_BLUE_PIN))
|GPIOPINCONFH(LED_BLUE_PIN,GPIOCONF(GPIO_MODE_OUTPUT2MHz,
GPIO_CNF_OUTPUT_PUSHPULL));
#else
LED_BLUE_GPIO->CRL = (LED_BLUE_GPIO->CRL & CONFMASKL(LED_BLUE_PIN))
| GPIOPINCONFL(LED_BLUE_PIN, GPIOCONF(GPIO_MODE_OUTPUT2MHz,
GPIO_CNF_OUTPUT_PUSHPULL));
15. #endif
The #if is preprocessor conditional directive, not the C language conditional instruction, so
before compilation the preprocessor depending on value of LED_BLUE_PIN choose proper
source code line and place them on source code file that will be compiled. Now, to turn LED on
we can use following sequence:
GPIOC->BSRR = (1 << LED_BLUE_PIN);
and for turn led OFF :
GPIOC->BRR = (1 << LED_BLUE_PIN);
Complete source code :
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 1. Blinking the LED.
// Copyright : Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
// e-mail : [email protected]
// Mobile No.: 9811506739
//=============================================================================
#include "stm32f10x.h"
#include "antilib_gpio.h"
//=============================================================================
// Defines
//=============================================================================
#define LED_BLUE_GPIO GPIOC
#define LED_BLUE_PIN 8
//=============================================================================
// main function
17. Lesson2. Reading the button
After blinking the LED, described in lesson 1, we can do another exercise - reading the button
state. On the STM32VLDISCOVERY board we have two buttons - one for resetting board (RST,
black) and one for user purpose (USER, blue). The USER button is connected to PA0 pin and
active states are high.
Creating project is similar to described in lesson 1. First thing to do to use this button is enable
clock for GPIO peripheral:
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPCEN;
Remember that we use also GPIOC, so we need turn on clock for both GPIOA and GPIOC.
Next, let's do some defines for USER button:
#define SW_USER_GPIO GPIOA
#define SW_USER_PIN 0
and now we can configure GPIO to work as input:
#if (SW_USER_PIN > 7)
SW_USER_GPIO->CRH = (SW_USER_GPIO->CRH & CONFMASKH(SW_USER_PIN)) |
GPIOPINCONFH(SW_USER_PIN, GPIOCONF(GPIO_MODE_INPUT,
GPIO_CNF_INPUT_FLOATING));
#else
SW_USER_GPIO->CRL = (SW_USER_GPIO->CRH & CONFMASKL(SW_USER_PIN)) |
GPIOPINCONFL(SW_USER_PIN, GPIOCONF(GPIO_MODE_INPUT,
GPIO_CNF_INPUT_FLOATING));
#endif
Now we can check in endless loop state of the button and turn LED on if is pressed:
while (1) {
if(SW_USER_GPIO->IDR & (1 << SW_USER_PIN))
LED_BLUE_GPIO->BSRR = (1 << LED_BLUE_PIN);
else
18. LED_BLUE_GPIO->BRR = (1 << LED_BLUE_PIN);
}
Complete code of example:
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 2. Reading from the switch.
// Copyright : Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
// e-mail : [email protected]
// Mobile No.: 9811506739
//=============================================================================
#include "stm32f10x.h"
#include "antilib_gpio.h"
//=============================================================================
// Defines
//=============================================================================
#define LED_BLUE_GPIO GPIOC
#define LED_BLUE_PIN 8
#define SW_USER_GPIO GPIOA
#define SW_USER_PIN 0
//=============================================================================
// main function
//=============================================================================
int main(void)
{
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPCEN;
20. After flashing MCU and pressing down the USER button blue LED will be turned on, after
release the button LED will be turned off.
Lesson 3. Blinking with Timer.
As i wrote in lesson 1, this is not the best way to make a delay :
for(dly = 0; dly < 500000; dly++);
CPU wasting time to counting this loop, and also time of delay is hard to define. This kind of
delay is maybe good for first program, but not for professional applications. So let's try blinking
LED with use one of STM32's timers. Look into section 13 of RM0041 document. This section
describes general purpose timers TIM2 to TIM5. These timers are a 16-bit timer with 16-bit
prescaler. Now, look into STM32F100RBT6 datasheetto section 3 "Pinouts and pin description".
Look for PC8 and PC9 in table 4. As you see, this pin can be connected to channels 3 and 4 of
timer TIM3. So let's use in this lesson timer TIM3 to blinking LEDs.
Make timer alive
First thing which we do is make timer counting. First of all, we need enable clock for timer
TIM3:
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
Now, we can configure timer. Let's assume that we want change state of LED each one second.
How to do it? You must know input frequency which clocking the timer. Now, look into file
system_stm32f10x.c at fragment:
#if defined (STM32F10X_LD_VL) || (defined STM32F10X_MD_VL) || (defined STM32F10X_HD_VL)
/* #define SYSCLK_FREQ_HSE HSE_VALUE */
#define SYSCLK_FREQ_24MHz 24000000
#else
/* #define SYSCLK_FREQ_HSE HSE_VALUE */
/* #define SYSCLK_FREQ_24MHz 24000000 */
/* #define SYSCLK_FREQ_36MHz 36000000 */
/* #define SYSCLK_FREQ_48MHz 48000000 */
21. /* #define SYSCLK_FREQ_56MHz 56000000 */
#define SYSCLK_FREQ_72MHz 72000000
#endif
As we use Medium Density Value Line microcontroller (MD_VL) we have two options of
System Core Clock : equal to HSE (High Speed External source) and 24 MHz Default value in
file is SYSCLK_FREQ_24MHz. Based on this macro definition, functions from file
system_stm32f10x.c will configure clock system of microcontroller to achieve 24MHz system
core clock. So our system frequency is 24MHz. Same frequency clock all peripherals, including
timer TIM3. But, how our timer works? In simplest mode timer is counting from 0 to value
stored in ARR register, then count again from 0 to ARR. When counter value is equal to ARR
the UIF flag in SR register is set.
How count one second with this timer? 24MHz of clock give us about 41 nanoseconds of one
timer tick. So our timer should count 24 million times to measure one second. But timer is only
16-bits with 16-bits prescaler. Almost like 32-bit timer, but with some limitations. If we don't
need high timer resolution we can prescale timer clock, by 24 000 and counting elapsing
milliseconds. One second is 1000 milliseconds, so look at code:
TIM3->PSC = 23999; // Set prescaler to 24 000 (PSC + 1)
TIM3->ARR = 1000; // Auto reload value 1000
TIM3->CR1 = TIM_CR1_CEN;// Enable timer
This is the simplest timer configuration. We set prescaler to 24k (remember - prescaler is PSC +
1) and auto reload register to 1000. Next, we enable the timer. From now, timer should be
counting. When timer achieve ARR value, the UIF flag will be set. So now we need chceck this
flag value, and toggle LED state, when flag is set (counter count to 1000). Code for check flag
and toggle LED:
if(TIM3->SR & TIM_SR_UIF)
{
TIM3->SR &= ~TIM_SR_UIF;
LED_BLUE_GPIO->ODR ^= (1 << LED_BLUE_PIN);
22. }
But when check this flag? Now, we check this flag in endless loop:
while (1) {
if(TIM3->SR & TIM_SR_UIF)
{
TIM3->SR &= ~TIM_SR_UIF;
LED_BLUE_GPIO->ODR ^= (1 << LED_BLUE_PIN);
}
}
Of course, this is not the best way to do this, but at this moment try this. Complete source code :
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 3. Blinking LED with Timer.
// Copyright : Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
// e-mail : [email protected]
// Mobile No.: 9811506739
//=============================================================================
#include "stm32f10x.h"
#include "antilib_gpio.h"
//=============================================================================
// Defines
//=============================================================================
#define LED_BLUE_GPIO GPIOC
#define LED_BLUE_PIN 8
23. //=============================================================================
// main function
//=============================================================================
int main(void)
{
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_IOPCEN;
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
#if (LED_BLUE_PIN > 7)
LED_BLUE_GPIO->CRH = (LED_BLUE_GPIO->CRH & CONFMASKH(LED_BLUE_PIN)) |
GPIOPINCONFH(LED_BLUE_PIN, GPIOCONF(GPIO_MODE_OUTPUT2MHz,
GPIO_CNF_OUTPUT_PUSHPULL));
#else
LED_BLUE_GPIO->CRL = (LED_BLUE_GPIO->CRL & CONFMASKL(LED_BLUE_PIN)) |
GPIOPINCONFL(LED_BLUE_PIN, GPIOCONF(GPIO_MODE_OUTPUT2MHz,
GPIO_CNF_OUTPUT_PUSHPULL));
#endif
TIM3->PSC = 23999; // Set prescaler to 24 000 (PSC + 1)
TIM3->ARR = 1000; // Auto reload value 1000
TIM3->CR1 = TIM_CR1_CEN;// Enable timer
while (1) {
if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set
{
TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag
LED_BLUE_GPIO->ODR ^= (1 << LED_BLUE_PIN); // toggle LED state
}
}
}
//=============================================================================
// End of file
24. //=============================================================================
After flashing STM32VLDISCOVERY board blue LED should be change their state each every
second. As i wrote - this is not the best way to use timer. The better ways are interrupts,
described in next lesson.
Lesson4. Blinking with timer interrupts
In lesson 3 we use timer TIM3 to measure time for blinking the LED, but shown method was not
perfect due to polling timer update flag. In this lesson we learn how to use timer interrupts for
blinking LED.
STM32 interrupts basics
Interrupt system of STM32 microcontrollers are described in section 8.1 of RM0041 document.
Now look into startup_stm32f10x_md_vl.s file. At line 61 (or one of their neighborhoods) is
defined vector table. This table consists from sequence of DCD (Define Constant Double word)
directive. Each of these directives defines address of handler for all interrupts on STM32
microcontroller, except the first element in this table, which is initial value of stack pointer. First
sixteen elements are reserved for vectors specific for Cortex-M3 core. Remaining positions can
be used by microcontroller vendor for their own interrupts vector. Now look at line 196. There is
defined DefauldHandler procedure, some exports functions name with WEAK keyword and
similar some of functions label. This is way to define 'default' functions, which are overrided by
definite it in other place of application. At line 281 there is only one assembler instruction:
B .
This is branch instruction to current line. It make endless loop. Now, if we don't define any
interrupt handler, all interrupt vectors will be pointed to this branch instruction. This prevents
from jumps to undefined locations when not handled interrupt occurs. Thanks to this, we can
define vectors only for used interrupts, without modifying vector table each time. How to define
our own interrupt handler? It is very simple:
void TIM3_IRQHandler(void)
{
// code of handler
}
25. When we define our handler, it's address will be placed on proper location in interrupts vectors
table. Define vector is one of things to make interrupt working. Next thing is enable interrupt in
NVIC (Nested Vectored Interrupt Controller). How do it? Like as this:
NVIC_EnableIRQ(TIM3_IRQn);
The last thing is enable peripheral to requests interrupt. For our timer we want enable update
event to generate an interrupt:
TIM3->DIER = TIM_DIER_UIE;
Now, we can place in interrupt handler our code for check flag and toggle LED state:
void TIM3_IRQHandler(void)
{
if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set
{
TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag
LED_BLUE_GPIO->ODR ^= (1 << LED_BLUE_PIN); // toggle LED state
}
}
Remember, interrupt flag must be cleared after enter to interrupt handler. Otherwise, interrupt
handler will be still executed.
Complete source code:
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 4. Blinking LED with Timer Interrupt.
// Copyright: Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
// e-mail : [email protected]
27. TIM3->CR1 = TIM_CR1_CEN; // Enable timer
NVIC_EnableIRQ(TIM3_IRQn); // Enable interrupt from TIM3 (NVIC level)
while (1) {}
}
//=============================================================================
// TIM3 Interrupt Handler
//=============================================================================
void TIM3_IRQHandler(void)
{
if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set
{
TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag
LED_BLUE_GPIO->ODR ^= (1 << LED_BLUE_PIN); // toggle LED state
}
}
//=============================================================================
// End of file
//=============================================================================
As we see, CPU execute endless loop that do nothing. But LED is blinking. Each every 1000
milliseconds state of LED is changing in the interrupt handler routine.
28. Lesson5. Blinking with timer hardware
After we successfully blink LED with interrupt from TIM3 we can do next step: blink LED only
with hardware - even without any single line of code! Of course, code for timer initialization will
be required, but blinking will be realized only by hardware. For do this, we use compare units of
timer TIM3. Now, go to section 13.3.8 of RM0041 document. There is described output compare
functionality of timer.
As you remember from previous lesson, two of discovery board LEDs can be connected to TIM3
channel 3 and 4. To connect LEDs to this channel we must configure PC8 and PC9 pin as
alternate function outputs. On PC8 and PC9 timer outputs are available only after remap. So we
need do full remap of TIM3 outputs. Now, go to section 7.4.2 of RM0041 document. There are
described register MAPR. As You see, to do full remap of TIM3 we need set both bits
TIM3_REMAP:
AFIO->MAPR = AFIO_MAPR_TIM3_REMAP; // Full TIM3 remap
To configure channel output for toggling on CH3 and CH4 output:
TIM3->CCMR2 = TIM_CCMR2_OC4M_0 | TIM_CCMR2_OC4M_1 |
TIM_CCMR2_OC3M_0 | TIM_CCMR2_OC3M_1; // Toggle output 3 & 4 on compare match
Now, we must enable compare on 3 & 4 channel :
TIM3->CCER = TIM_CCER_CC4E | TIM_CCER_CC3E;
and set compare values :
TIM3->CCR3 = 250; // Compare 4 with 250
TIM3->CCR4 = 500; // Compare 4 with 500
Complete source code :
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 5. Blinking LED with Timer Hardware.
// Copyright : Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
31. After flashing MCU both LEDs will be blinking with 500ms period with 250ms delay between
blue and green. And no code in endless loop and no interrupt!
Lesson6. Pulse Width Modulation (PWM)
In lesson 5 we learn how to blink led with Compare unit of timer TIM3. Compare unit can be
also used in pulse width modulation mode for brightness control of LED. Now, go to section
number 13.3.9 of RM0041 document.
Different PWM duty
Configuration of compare module is slightly different from previous example:
TIM3->CCMR2 = TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4M_1 |
TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1; // PWM mode on channel 3 & 4
Now, CCR3 and CCR4 registers holds PWM duty value. Write initial duty value to registers:
TIM3->CCR3 = 0; // Start PWM duty for channel 3
TIM3->CCR4 = 500; // Start PWM duty for channel 4
Each time when timer reloads new value we want to change current PWM duty in both channels.
So in interrupt handler from TIM3 we well be change duty on both channels. On CH3 we
increase duty by 1% each time, on CH4 we decrease duty by 1% each time:
void TIM3_IRQHandler(void)
{
if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set
{
TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag
TIM3->CCR3 += 5; // increase ch3 duty
if(TIM3->CCR3 == 500) // if maximum
TIM3->CCR3 = 0; // set to zero
32. TIM3->CCR4 -= 5; // decrease ch4 duty
if(TIM3->CCR4 == 0) // if minimum
TIM3->CCR4 = 500; // set to maximum
}
}
Complete source code :
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 6. Pulse Width Modulation.
// Copyright: Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
// e-mail : [email protected]
// Mobile No.: 9811506739
//=============================================================================
#include "stm32f10x.h"
#include "antilib_gpio.h"
//=============================================================================
// Defines
//=============================================================================
#define LED_BLUE_GPIO GPIOC
#define LED_BLUE_PIN 8
#define LED_GREEN_GPIO GPIOC
#define LED_GREEN_PIN 9
//=============================================================================
// main function
//=============================================================================
34. TIM3->CCMR2 = TIM_CCMR2_OC4M_2 | TIM_CCMR2_OC4M_1 |
TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1; // PWM mode on channel 3 & 4
TIM3->CCER = TIM_CCER_CC4E | TIM_CCER_CC3E; // Enable compare on channel 3 & 4
TIM3->CR1 = TIM_CR1_CEN; // Enable timer
TIM3->DIER = TIM_DIER_UIE; // Enable update interrupt (timer level)
NVIC_EnableIRQ(TIM3_IRQn); // Enable interrupt from TIM3 (NVIC level)
while (1) {}
}
//=============================================================================
// TIM3 Interrupt Handler
//=============================================================================
void TIM3_IRQHandler(void)
{
if(TIM3->SR & TIM_SR_UIF) // if UIF flag is set
{
TIM3->SR &= ~TIM_SR_UIF; // clear UIF flag
TIM3->CCR3 += 5; // increase ch3 duty
if(TIM3->CCR3 == 500) // if maximum
TIM3->CCR3 = 0; // set to zero
TIM3->CCR4 -= 5; // decrease ch4 duty
if(TIM3->CCR4 == 0) // if minimum
TIM3->CCR4 = 500; // set to maximum
}
}
//=============================================================================
// End of file
//=============================================================================
35. Lesson 7 Analog to digital converter (ADC)
Every STM32 microcontroller has at least one 12-bit analog to digital converter. In
STM32F100RBT6 microcontroller there are one ADC with 16 input channels. In this example
we use one of analog input of MCU to control PWM duty of LED brightness (described in lesson
6). Now, we must connect external potentiometer to STM32VLDISCOVERY board like on
the schematic.
ADC peripheral is described in section 10 of RM0041 document. So read this section now.
Now, I will introduce next part of "AntiLib" project: antilib_adc.h. In this file are some intuitive
macros for easier configuration of ADC peripheral. There are macros that define sample time:
#define SAMPLE_TIME_1_5 0
#define SAMPLE_TIME_7_5 1
#define SAMPLE_TIME_13_5 2
#define SAMPLE_TIME_28_5 3
#define SAMPLE_TIME_41_5 4
#define SAMPLE_TIME_55_5 5
#define SAMPLE_TIME_71_5 6
#define SAMPLE_TIME_239_5 7
and shifting macros for each channel :
#define ADC_SAMPLE_TIME0(x) (x << 0)
#define ADC_SAMPLE_TIME9(x) (x << 27)
#define ADC_SAMPLE_TIME10(x) (x << 0)
#define ADC_SAMPLE_TIME17(x) (x << 21)
With this macros configuration of sample time for channels are clear and readable:
ADC1->SMPR2 = ADC_SAMPLE_TIME0(SAMPLE_TIME_239_5);
To define length of sequence is prepared macro:
36. #define ADC_SEQUENCE_LENGTH(x) (x << 20)
This macro shift macro parameter by 20 bits. Sequence lenght is numbered from 0. For only one
channel in sequence configuration looks like this :
ADC1->SQR1 = ADC_SEQUENCE_LENGTH(0); // One channel in sequence
I'm prepare also macros for definig each sequence channels :
// SQR3
#define ADC_SEQ1(x) (x << 0)
#define ADC_SEQ2(x) (x << 5)
#define ADC_SEQ6(x) (x << 25)
// SQR2
#define ADC_SEQ7(x) (x << 0)
#define ADC_SEQ12(x) (x << 25)
// SQR1
#define ADC_SEQ13(x) (x << 0)
#define ADC_SEQ16(x) (x << 15)
Complete configuration of ADC peripheral:
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_CONT; // Turn on ADC, enable continues mode
ADC1->SQR1 = ADC_SEQUENCE_LENGTH(0); // One channel in sequence
ADC1->SQR3 = ADC_SEQ1(0); // ADC channel 0 is first in sequence
ADC1->SMPR2 = ADC_SAMPLE_TIME0(SAMPLE_TIME_239_5); // sample time for first channel
ADC1->CR1 = ADC_CR1_EOCIE; // Enable interrupt form End Of Conversion
NVIC_EnableIRQ(ADC1_IRQn); // Enable interrupt form ACD1 peripheral
ADC1->CR2 |= ADC_CR2_ADON; // Turn on conversion
Now we can define handler for interrupt from ADC End of Conversion:
37. void ADC1_IRQHandler (void)
{
if(ADC1->SR & ADC_SR_EOC)
{
TIM3->CCR3 = ADC1->DR; // Copy value of analog input to PWM duty register
}
}
Complete source code of example:
//=============================================================================
// STM32VLDISCOVERY tutorial
// Lesson 7. Analog to Digital Convertor.
// Copyright: Gaurav Verma, Assistant Professor, ECE Department.
// Jaypee Institute of Information Technology, Sector-62, Noida.
// e-mail : [email protected]
// Mobile No.: 9811506739
//=============================================================================
#include "stm32f10x.h"
#include "antilib_gpio.h"
#include "antilib_adc.h"
//=============================================================================
// Defines
//=============================================================================
#define LED_BLUE_GPIO GPIOC
#define LED_BLUE_PIN 8
#define AIN0_GPIO GPIOA
#define AIN0_PIN 0
//=============================================================================
39. TIM3->CCMR2 = TIM_CCMR2_OC3M_2 | TIM_CCMR2_OC3M_1; // PWM mode on channel 3
TIM3->CCER = TIM_CCER_CC3E; // Enable compare on channel 3
TIM3->CR1 = TIM_CR1_CEN; // Enable timer
ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_CONT; // Turn on ADC, enable continues mode
ADC1->SQR1 = ADC_SEQUENCE_LENGTH(0); // One channel in sequence
ADC1->SQR3 = ADC_SEQ1(0); // ADC channel 0 is first in sequence
ADC1->SMPR2 = ADC_SAMPLE_TIME0(SAMPLE_TIME_239_5); // sample time for first channel
ADC1->CR1 = ADC_CR1_EOCIE; // Enable interrupt form End Of Conversion
NVIC_EnableIRQ(ADC1_IRQn); // Enable interrupt form ACD1 peripheral
ADC1->CR2 |= ADC_CR2_ADON; // Turn on conversion
while (1) {}
}
//=============================================================================
// ADC1 Interrupt handler
//=============================================================================
void ADC1_IRQHandler (void)
{
if(ADC1->SR & ADC_SR_EOC)
{
TIM3->CCR3 = ADC1->DR;
}
}
//=============================================================================
// End of file
//=============================================================================
Changing value of analog input should change LED brightness.
40. Lesson8. Communication with USART
In this lesson i show you the simplest way to use USART for communication with other device
(for example your PC).
USART configuration
USART peripheral is described in section 23 of RM0041 document. There is lot of data to read,
but for simple asynchronous communication we don't need read whole chapter. Main features are
described in sections from 23.3.1 to 23.3.4. To use USART peripheral we must enable clock for
it, and for GPIO used by peripheral. It is obvious, but sometimes easy to forget. USART1, which
are used in this lesson, is connected to APB2 bus, and use GPIOA (by default). Code for enable
clock for USART1 and GPIOA:
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_USART1EN;
After enabling clock for USART1 peripheral, we can configure it. What we need to do? At this
moment we need two things: enable usart transmitter, and sets baudrate. Enabling transmitter is
done by setting UE (USART enable) and TE (transmitter enable) bits in CR1 register of
USART1 peripheral :
USART1->CR1 = USART_CR1_UE | USART_CR1_TE;
In RM0041 document there is shown sophisticated way to calculate USART baudrate. There is
mantissa and fractional part of divider, but forget about them! Calculating baudrate is easier than
shown in reference manual. So how to calculate value of BRR register? Just divide peripheral
clock by baudrate! We want configure USART for communication with transmission speed
equal to 115200 bits per second. It’s done by one line :
USART1->BRR = (SystemCoreClock / 115200);
What is SystemCoreClock? This is variable sets by SystemInit function that holds current system
frequency. By default, APB2 bus clock is equal to system frequency; we can use it to calculate
baudrate.
Sending single character
In this lesson I show simplest way to sending data - using pooling. Before write data to DR
register, we check state of TXE (transmitter empty) flag. When this flag is clear, we can't write to
DR register. High value of this flag mean that is no data in transmit buffer (previous data just be
sent or there is first transmission) and we can write new data to send. So let's create function
dedicated to sending one byte via USART:
41. void USART_PutChar(uint8_t ch)
{
while(!(USART1->SR & USART_SR_TXE));
USART1->DR = ch;
}
Sending text
When we can send single character we can write function for sending typical for C language
null-terminated strings. Null terminated string is character array, that last element has value zero.
Empty string has one element - value zero. So before sending character we must check if
character has different value than zero. If this condition is true, we can send first character and
increment pointer to prepare next character to send. Repeat this in loop until pointer will be
pointed to character value zero.
void USART_PutString(uint8_t * str)
{
while(*str != 0)
{
USART_PutChar(*str);
str++;
}
}
Now, we are ready to send text by USART:
USART_PutString(text); // argument is pointer variable
USART_PutString("Some text to send"); // argument is constant string
44. USART_TX_GPIO->CRL = (USART_TX_GPIO->CRL & CONFMASKL(USART_TX_PIN)) |
GPIOPINCONFL(USART_TX_PIN, GPIOCONF(GPIO_MODE_OUTPUT2MHz,
GPIO_CNF_AFIO_PUSHPULL));
#endif
USART1->CR1 = USART_CR1_UE | USART_CR1_TE;
USART1->BRR = (SystemCoreClock / 115200);
while (1)
{
USART_PutString(text);
for(dly = 0; dly < 1000000; dly++);
}
}
//=============================================================================
// End of file
//=============================================================================
Effect of this code:
45. Lesson9. Analog to digital converter (ADC) with Direct Memory Access (DMA)
In lesson 7 I introduce analog to digital converter, that measure voltage on one analog input. For
measure voltage on more than one input the best way is use DMA for automatic transfer data
from ADC to memory. Direct memory access is a mechanism that allows to transferring data
between memories without usage of CPU.
ADC configuration
In comparison to ADC configuration from lesson 7, we must enabled two new modes in ADC
peripheral: SCAN mode and DMA mode. Scan mode allows for automatic scanning selected
channels without interaction from CPU. After conversion of each channel immediately starts
new conversion of next channel in sequence. We can scan up to 16 regular channels in the
sequence. In scan mode there is risk of overwrite data from previous conversion, because all
conversion results are stored in this same data register (DR). For this reason in connection with
SCAN mode are used DMA mode, that allows for automatic storage of conversion values in data
memory after each conversion.
ADC1->CR2 = ADC_CR2_ADON | // turn on ADC
ADC_CR2_CONT | // enable continues mode
ADC_CR2_DMA; // enable DMA mode
ADC1->CR1 = ADC_CR1_SCAN; // enable scan mode
Configuration of ADC sequencer:
ADC1->SQR1 = ADC_SEQUENCE_LENGTH(3); // four channels in sequence
ADC1->SQR3 = ADC_SEQ1(0) | // channel 0 is first in sequence
ADC_SEQ2(1) | // channel 1 is second in sequence
ADC_SEQ3(2) | // channel 2 is third in sequence
ADC_SEQ4(3) ; // channel 3 is fourth in sequence
ADC1->SMPR2 = ADC_SAMPLE_TIME0(SAMPLE_TIME_239_5) | // sample time for first channel in
sequence
ADC_SAMPLE_TIME1(SAMPLE_TIME_239_5) | // sample time for second channel in sequence
ADC_SAMPLE_TIME2(SAMPLE_TIME_239_5) | // sample time for third channel in sequence
46. ADC_SAMPLE_TIME3(SAMPLE_TIME_239_5) ; // sample time for fourth channel in sequence
Variable for storing conversion values :
vu16 AIN[4]; // 4 locations
DMA configuration
Before we use DMA for transferring data between two areas of memory space of STM32
microcontroller, we have to say to DMA peripheral some informations, like as : source address
(data register of ADC), destination address (table for conversions results), number of transfers
(amount of scanned input channels).
DMA1_Channel1->CPAR = (uint32_t)(&(ADC1->DR)); // peripheral (source) address
DMA1_Channel1->CMAR = (uint32_t)AIN; // memory (destination) address
DMA1_Channel1->CNDTR = 4; // 4 transfers
DMA1_Channel1->CCR |= DMA_CCR1_CIRC | // circular mode enable
DMA_CCR1_MINC | // memory increment mode enable
DMA_CCR1_MSIZE_0 | // memory size 16 bits
DMA_CCR1_PSIZE_0; // peripheral size 16 bits
DMA1_Channel1->CCR |= DMA_CCR1_EN ; // Enable channel
Sending conversion results
For sending result we use code from lesson 8.
do{
sprintf(str, "0:%dtt1:%dtt2:%dtt3:%dr", AIN[0], AIN[1], AIN[2], AIN[3]);
USART_PutString(str);
for(dly = 0; dly < 1000000; dly++);
}while(1);