Precautions for using AVR microcontroller I/O ports

Publisher:平凡梦想Latest update time:2020-02-06 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Correctly set the DDRx direction register before performing read and write operations on the I/O port.


2. The initial state of the I/O port after reset is all input working mode, the internal pull-up resistor is invalid, and the external pin is in a three-state high-impedance input state.


3. When the I/O port works in input mode and you want to read the level on the external pin, you should read the value of PINxn instead of the value of PORTxn.


4. When the I/O operates in input mode, use or not use the internal pull-up resistor according to the actual situation.


5. Once the I/O port's working mode is set from output to input, you must wait for 1 clock cycle before you can correctly read the value of the external pin PINxn.

Reference address:Precautions for using AVR microcontroller I/O ports

Previous article:Introduction to AVR Common Library Functions
Next article:Building your own AVR RTOS (Part 7: Preemptive Kernel)

Recommended ReadingLatest update time:2024-11-16 13:03

How competitive is the BMW I4?
Due to the cancellation of this year's Geneva Motor Show, BMW chose to launch its first pure electric four-door coupe, the BMW i4 concept car, online for the first time. This car will be produced in Europe in 2021. It is a truly pure electric sedan that BMW can show off. When paired with BMW's I-Next model, it is a tr
[Embedded]
How competitive is the BMW I4?
Connecting GPS module via I2C bus based on ATtiny841
This article mainly describes how to connect a simple GPS module via the I2C bus. The controller used is ATtiny841: Introduction Incorporating GPS into a project is a very daunting task. First you have to correctly parse the NMEA sentences returned by the GPS module you are using, then if you are doing any calcul
[Microcontroller]
Connecting GPS module via I2C bus based on ATtiny841
NXP Launches Next-Generation Secure and Energy-Efficient i.MX 91 Series, Expanding Linux Capabilities for a Broad Range of Edge Applications
New i.MX 9 family members simplify development of cost-effective edge devices, helping build scalable, reliable platforms that require security, high performance and Linux support Shanghai, China - June 1, 2023 - NXP Semiconductors NV (NXP Semiconductors NV) officially released the i.MX 91 applica
[Embedded]
In-vehicle gateway solution based on NXP i.MX8QXP
The automotive gateway controller is a core component in the vehicle's electronic and electrical architecture. As the data interaction hub of the vehicle network, it can route CAN, LIN, MOST, FlexRay and other network data among different networks. The network nodes inside the car are like stations. When sending inf
[Automotive Electronics]
In-vehicle gateway solution based on NXP i.MX8QXP
Solution to setting I2C_FLAG_BUSY in STM32
The touch screen IC on the stm32f429-disco is STMPE811, which uses I2C communication. The use of this IC is not difficult. It includes 8-channel 12-bit AD, 8 GPIO ports, plus 128set FIFO and several registers. The problem lies with the I2C IP core of STM32. Many people have complained about it online. The main probl
[Microcontroller]
Solution to setting I2C_FLAG_BUSY in STM32
AVR MCU I/O Port Application
1. Port registers and configuration When used as general digital I/O, each pin has 3 register bits: DDRxn, PORTxn, PINxn                                    2. Configuration instance       (1) PA configured as output             DDRA = 0XFF;             PORTA = 0X03;    //PA output value is 0x03     (
[Microcontroller]
AVR MCU I/O Port Application
MCU I2C addressing mode
The previous section introduced the timing process of each bit signal of I2C, and I2C communication also has fixed timing requirements in byte-level transmission. After the start signal (Start) of I2C communication, a slave address must be sent first. This address has a total of 7 bits, and the 8th bit that follows is
[Microcontroller]
MCU I2C addressing mode
What is the load capacity of the I2C serial expansion bus? What is the maximum signal transmission rate?
A: Since all I2C bus devices are CMOS devices, the bus has sufficient current driving capability. The number of devices extended on the bus is not limited by the current driving capability, but by the total capacitance load. The capacitance load capacity of the I2C bus is 400 pF (can reach 4000pF through driver expans
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号