First, check the bottom board schematic diagram of TQ210
This time, only KEY1 and KEY2 are operated. Search for XEINT0 in the TQ210 core board schematic diagram.
It can be seen that KEY1 and KEY2 are connected to the GPH0_0 and GPH0_1 pins of S5PV210 respectively.
This programming uses the query method. You need to set these two pins to input mode, and then read the pin status in a loop. When the user presses the button, the corresponding pin is at a low level and the LED status changes.
View S5PV210 chip manual
start.S
.global _start @Declare a global label
_start:
bl main @jump to C function to execute
halt:
b halt @Dead loop
key.c
#define GPC0CON *((volatile unsigned int *)0xE0200060)
#define GPC0DAT *((volatile unsigned int *)0xE0200064)
#define GPH0CON *((volatile unsigned int *)0xE0200C00)
#define GPH0DAT *((volatile unsigned int *)0xE0200C04)
void delay(volatile unsigned int t)
{
volatile unsigned int t2 = 0xFFFF;
while (t--)
for (; t2; t2--);
}
int main()
{
int key_val = 0;
int bit;
GPC0CON &= ~(0xFF << 12);
GPC0CON |= 0x11 << 12; // Configure GPC0_3 and GPC0_4 as outputs: LED1 and LED2
GPH0CON &= ~(0xFF << 0); // Configure GPH0_0 and GPH0_1 as input: key1 and key2
while (1)
{
key_val = GPH0DAT & 0x3;
if (key_val)
{
delay(500000); // Anti-shake delay
key_val = GPH0DAT & 0x3;
if (key_val)
{
if (0x01 == key_val) // key1
GPC0DAT ^= 1 << 3; // toggle LED1
else if (0x02 == key_val) // key2
GPC0DAT ^= 1 << 4; // toggle LED2
}
}
}
return 0;
}
Makefile
key.bin: start.o key.o
arm-linux-ld -Ttext 0x20000000 -o key.elf $^
arm-linux-objcopy -O binary key.elf $@
arm-linux-objdump -D key.elf > key.dis
key.o : key.c
arm-linux-gcc -c $< -o $@
start.o : start.S
arm-linux-gcc -c $< -o $@
clean:
rm *.o *.elf *.bin *.dis
For the download method, please refer to "TQ210 Bare Metal Programming (1) - Lighting up an LED"
After downloading the program:
Press key1, LED1 lights up, press key1 again, LED1 turns off
Press key2, LED2 lights up, press key2 again, LED2 turns off
Previous article:S5PV210 (TQ210) study notes - 8-bit HWECC and YAFFS2 OOB layout
Next article:TQ210 bare metal programming - key lighting (Part 2)
- 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
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- 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
- Wireless communication, 5G, RF, antenna and several concepts and indicators
- Happy Lantern Festival! Guess the lantern riddles and have fun
- How to make an automatic switch when there are 3 5V input ports on a circuit board?
- "Operational Amplifier Parameter Analysis and LTspice Application Simulation" Reading Notes Part 3 - Noise
- 280 million yuan in subsidies returned! A Russian supercomputer company's self-developed CPU failed to meet the standards and was sued by the Ministry of Industry and Trade
- I have a question about the drive circuit.
- LSM6DSOX sensor test hardware platform sharing
- Oh my god! My air conditioner has become a spirit!
- Wireless RF communication using nRF24L01 module
- Today at 10:00 AM, live broadcast with awards: ADI's technologies and products in China's energy internet applications