0% found this document useful (0 votes)
21 views

Chapter 4 Digital Input and Output

Chapter 4 covers digital input and output (I/O) for ARM Cortex-M microcontrollers, focusing on interfacing GPIO pins with external voltage levels. It discusses the setup and usage of digital I/O on the STM32F4 microcontroller, including handling digital inputs from switches and high voltage outputs. The chapter also addresses methods to protect the microcontroller from high voltage and current loads.

Uploaded by

varshini10798
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Chapter 4 Digital Input and Output

Chapter 4 covers digital input and output (I/O) for ARM Cortex-M microcontrollers, focusing on interfacing GPIO pins with external voltage levels. It discusses the setup and usage of digital I/O on the STM32F4 microcontroller, including handling digital inputs from switches and high voltage outputs. The chapter also addresses methods to protect the microcontroller from high voltage and current loads.

Uploaded by

varshini10798
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 15

Chapter 4

Digital Input and Output

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Table of Contents
1. Introduction
2. Microcontroller Architecture
3. Software Development Platforms
4. Digital Input and Output
5. Interrupts and Power Management
6. Timing Operations
7. Conversion Between Analog and Digital Values
8. Digital Communication
9. Memory Operations
10. Real-time Operating Systems
11. LCD, Touch Screen, and Graphical User Interface Formation
12. Introduction to Digital Signal Processing
13. Introduction to Digital Control
14. Introduction to Digital Image Processing
15. Advanced Topics

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
LAYOUT
 Introduction
 Bit Values as Voltage Levels
 Interfacing Voltage Levels with the Microcontroller
 Digital Input from a Switch or Button
 Digital I/O with High Voltage Values
 Digital Output to a Load Requiring High Current and Voltage
Values
 Digital I/O Setup on the STM32F4 Microcontroller
 Circuit Diagram of a Pin and Its Setup via Associated Registers
 GPIO Registers in Memory Map of the STM32F4 Microcontroller
 Setting Up GPIO Registers
 Digital I/O Usage on the STM32F4 Microcontroller
 C Language Usage
 C++ Language Usage
 MicroPython Usage
bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Introduction
 The microcontroller should interact with the outside world.

 To do so, we will introduce interfacing digital input and output (digital I/O) to
and from the microcontroller in this chapter.

 Peripheral units dedicated for this operation are called general purpose input
and output (GPIO) pins.

 These will form a bridge between code-based bit values (logic level 0 or 1)
and voltage levels to be fed or received from the outside world.

 We will show how the logic level 0 or 1 can be represented in voltage level.

 We will deal with interfacing these voltage levels with the microcontroller.

 We will focus on digital I/O setup within the STM32F4 microcontroller followed
by its usage.

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Bit Values as Voltage Levels
 If we start interacting the
microcontroller with the outside
world, then abstract representations
such as logic level 0 or 1 do not
mean much.

 We should associate these logic


levels with actual voltage values
used in the microcontroller
bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Bit Values as Voltage Levels

LVTTL LVCMOS
3.3 V logic levels
bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller

While using a GPIO pin of the


microcontroller, some applications
may require special consideration.
 Digital input from a switch or button
 Digital I/O with high voltage values
 Digital output to a load requiring high
current and voltage values

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller
Digital input from a switch or button
 Switch bouncing is a serious problem when a
button (or switch) is used in a digital system.
 Software solutions
 adding a delay while reading the input in the code.
 using a shift register.
 Hardware Solution

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller

Digital input from a switch or button

Active high and low input circuit diagrams for the push button

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller

Digital I/O with high voltage values

 Digital input to the microcontroller can originate


from a source, such as sensor or external device.
 Directly connecting such a source to the
microcontroller can damage or burn out the GPIO
pin circuitry.
 There are two methods to handle such situations.
 using a level shifter between the high voltage source
or load and microcontroller.
 using high voltage tolerant pins of the microcontroller,
if there are any.

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller

Basic unidirectional
voltage level shifter

Basic bidirectional
voltage level shifter

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller

 Digital output to a load requiring high current and


voltage values.

 We may want to drive heavy loads, such as a motor


or power LEDs, by the microcontroller.

 Voltage and current output from the microcontroller


may not be sufficient for them. There are three
methods to handle these cases using
 transistors
 optocouplers
 relays

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller

Driving a heavy load with transistor

BJT MOSFE
T
bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Interfacing Voltage Levels with
the Microcontroller

Optocoupler between the load and microcontroller pin

bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython
Digital I/O Setup on the
STM32F4 Microcontroller

Circuit diagram of a pin


bedded System Design with ARM Cortex-M Microcontrollers: Applications with C, C++ and MicroPython

You might also like