We often need to set an I/O port as output, input, or input with pull-up. In fastavr, this is how it works:
Example:
Set the entire A port as output:
ddra=255 'Decimal representation, the single quote at the beginning or end of a line is a comment, the default color is green
ddra=&hff 'Hexadecimal representation, hexadecimal number plus prefix &h
ddra=&B11111111 ' Binary representation, binary number plus prefix &B
Set the high four bits of port A as output and the low four bits as input:
ddra=&B11110000
porta=porta Or &b00001111 'Use the logic OR method to turn on the pull-up of the lower four bits without affecting the output state of the upper four bits
Set the entire B port as input:
ddrb=0
ddrb=&h00
ddrb=&b00000000
Enable all pull-ups on port B, or enable partial pull-ups on port B:
portb=255: portb=&b11000011 'When we want to write multiple statements in one line, please separate them with colons
To set a single I/O port:
set ddra.7 'porta seventh position is the output port
reset ddrb.0 'portb.0 is the input port
set portb.0 'Then turn on the pull-up of portb.0
When we want to clear some bits without affecting other bits, we use logical AND.
porta=porta and &B01111110 'porta.7, porta.0 are cleared without affecting other bits
Summary: If we only want to set a single input and output port, we can use the set and reset instructions. If we want to change several bits of a port at the same time, it is best to use
Use logical AND or NOT to complete it. AND can be used to clear, OR can be used to set, and NOT can be used to negate.
Previous article:AVR C language programming style
Next article:AVR GCC Chinese Manual
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Brief Analysis of Automotive Ethernet Test Content and Test Methods
- How haptic technology can enhance driving safety
- Looking for chip model, ST silk screen 504
- Silergy GaN fast charging evaluation board test report
- Basic Robot Making and Programming.rar
- Impedance matching in circuits
- HiSilicon recruits analog chip design engineers
- Pimoroni Pico libraries and examples
- Key points of machine vision technology
- Four ways to wirelessly transmit data collected by sensors to the monitoring server
- [National Technology N32WB452 Review] Second issue, lighting and ADC usage in the full version of RT-Thread
- Voltage stabilization