Today, we use the interrupt method to program the button lighting of the TQ210 bare machine.
#define GPC0CON *((volatile unsigned int *)0xE0200060)
#define GPC0DAT *((volatile unsigned int *)0xE0200064)
#define GPH0CON *((volatile unsigned int *)0xE0200C00)
#define GPH0DAT *((volatile unsigned int *)0xE0200C04)
#define EXT_INT_0_CON *((volatile unsigned int *)0xE0200E00)
#define EXT_INT_0_MASK *((volatile unsigned int *)0xE0200F00)
#define VIC0INTSELECT *((volatile unsigned int *)0xF200000C)
#define VIC0INTENABLE *((volatile unsigned int *)0xF2000010)
#define VIC0VECTADDR0 *((volatile unsigned int *)0xF2000100)
#define VIC0VECTADDR1 *((volatile unsigned int *)0xF2000104)
#define VIC0ADDRESS *((volatile unsigned int *)0xF2000F00)
#define EXT_INT_0_PEND *((volatile unsigned int *)0xE0200F40)
extern void key_isr(void);
void key_handle()
{
volatile unsigned char key_code = EXT_INT_0_PEND & 0x3;
VIC0ADDRESS = 0; /* Clear interrupt vector register */
EXT_INT_0_PEND |= 3; /* Clear interrupt pending register*/
if (key_code == 1) /* key1 */
GPC0DAT ^= 1 << 3; /* toggle LED1 */
else if (key_code == 2) /* key2 */
GPC0DAT ^= 1 << 4; /* toggle LED2 */
}
int main()
{
GPC0CON &= ~(0xFF << 12);
GPC0CON |= 0x11 << 12; /* Configure GPC0_3 and GPC0_4 as output: LED1 and LED2 */
GPH0CON |= 0xFF << 0; /* Configure GPH0_0 and GPH0_1 as external interrupts: key1 and key2 */
EXT_INT_0_CON &= ~(0xFF << 0);
EXT_INT_0_CON |= 2 | (2 << 4); /* Configure EXT_INT[0] and EXT_INT[1] as falling edge trigger*/
EXT_INT_0_MASK &= ~3; /* Unmask external interrupts EXT_INT[0] and EXT_INT[1] */
VIC0INTSELECT &= ~3; /* Select external interrupt EXT_INT[0] and external interrupt EXT_INT[1] as IRQ type interrupt*/
VIC0INTENABLE |= 3; /* Enable external interrupts EXT_INT[0] and EXT_INT[1] */
VIC0VECTADDR0 = (int)key_isr; /* When EXT_INT[0] triggers an interrupt, that is, when the user presses key1,
The CPU will automatically assign the value of VIC0VECTADDR0 to VIC0ADDRESS and jump to this address to execute */
VIC0VECTADDR1 = (int)key_isr;
while (1);
return 0;
}
Previous article:TQ210 bare metal programming (3) - keystroke (query method)
Next article:TQ210 bare metal programming (8) - PWM
- 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
- Share the timer program of TMS320C6747
- [Good memory is not as good as bad writing] 1. F1 MDK transplantation FreeRTOS practice record 1-dynamic multitasking
- EEWORLD University ----TI DLP? Labs - Light control
- [Experience sharing] [Voice and vision module based on ESP32S3] Software development progress - using openmvIDE to light a lamp
- Recently, my boss has paid special attention to the program protection of laser equipment. Do you have any good methods?
- SensorTile.box firmware update
- CC2640 CC1310 high and low temperature test
- Wanted STM32F103 series chips
- Is it true that without a diode there is no way to oscillate?
- EEWORLD University Hall----Live Replay: Microchip RISC-V Safe Place