Many IO ports have multiplexing functions. At the beginning, I only learned about the input and output to complete the functions of the keyboard and display. I used the DEMO of the experimental board DP256. The display was a small LED light and the keyboard was a switch.
Reference address:Starting from the IO port_HCS12 study notes (1)
A, B, E, and K can control whether to pull up the resistor through the register, and they share an enable bit PUCR.
H, J, M, P, S, and T can also be used as ordinary IO ports, which are basically similar to port A.
1.1 Output
The program uses the output of PORTB to control the brightness of the small light. Setting DDRB to high enables the output of port B, which is the initialization of the IO port. The value of PORTB is used to control the initial brightness of the small light.
The software can be used to control the order in which the small lights light up and other functions.
1.2 Input
Same as above, DDR becomes low for input. Here, in order to realize the keyboard, the IO port is set to pull up, which is high level when it is not connected. The IO port can also set interrupts, which are not used here, and no relevant information has been found, so it is left blank for now.
General register table, taking port H as an example:
Data Direction Register DDRH
IO port register PTH
When the input register PTIH pin is input, the value is the corresponding level. When output, monitor whether the pin is overloaded or short-circuited, and the value is 1.
Low power drive register RDRH
Pull-up and pull-down enable register PERH
Pull-up and pull-down selection register PPSH 0 is pull-up, 1 is pull-down
The initial understanding of embedded systems also needs to start with the simplest examples, such as small lights and keyboards. The development board I use is Motorola's HCS12dp256b demo board. The keyboard only has an eight-bit switch corresponding to port H, and the LED light is also the simplest, corresponding to port B. What is easy to make mistakes in the beginning is the hardware, whether the light is 1 or 0, or whether the switch direction is 1 when it is on or 1 when it is off. On my board, the switch is closed to 0, and I couldn't get it right at the beginning because I didn't understand this aspect. Finally, after pulling up the switch port (H), the problem was solved.
Previous article:FLASH debugging_HCS12 study notes (6)
Next article:HCS12 interrupt vector table
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- Rambus Launches Industry's First HBM 4 Controller IP: What Are the Technical Details Behind It?
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
Guess you like
- Question about transistor base emitter saturation voltage
- Problems with switching tube oscillation and inversion
- Can this be done at the input end of the optocoupler?
- KiCad 5.1.6 released
- [Jiangxiang Technology] Today I won a bottle of 2499 Jiangxiang Technology
- Today at 10:00 AM, live broadcast with prizes: Arrow Electronics & ADI join hands to design flyback isolated power supply without optocoupler
- I heard that Shengbang’s products are very popular recently. What do netizens think?
- Problems with the MAX1978
- [Silicon Labs Development Kit Review] + First Project & GPIO Control LED
- 【TI recommended course】#Lecture on basic knowledge of electronic circuits#