Port initialization
#include "stm32f10x.h"//PA15void KEY_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); //Enable external clock GPIO_InitStructure.GPIO_Pin = GPIO_Pin_15; //PA15 pull-up input GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(GPIOA, &GPIO_InitStructure); }1234567891011
Main function
#include "stm32f10x.h" int main(void) { SystemInit(); //System clock initialized to 72M SYSCLK_FREQ_72MHz delay_init(72); LED_Heat(); KEY_Init(); while(1) { if(KEY1==1) { delay_ms(10); if(KEY1==1) { while(KEY1==1) { ; } LED0=!LED0; } } } }
Previous article:STM32 Experiment 4: Key Interrupt
Next article:STM32 Experiment 1: IO Output
Recommended ReadingLatest update time:2024-11-16 12:49
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- 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
- 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!
- 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
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- [ESK32-360 Review] + OLED screen driver
- How to use MSP430 watchdog
- 0-10V LED Dimming Latest Solution (1)
- Open source development board CANPico
- Melexis High Reliability Programmable Hall Switch, you are invited to watch the live broadcast at 10:00 on May 21st
- Register for the live broadcast to win [bracelet, camera, umbrella, mobile phone holder] Rohde & Schwarz USB 3.2 conformance test
- Newbie question, please help! I just learned analog electronics and built a simple circuit using Multisim
- 【Zero Knowledge ESP8266】Tutorial: Mobile APP Control RGB LED
- The application of CAN bus data in automobile digital technology is the starting point
- TI AM335 Embedded Hardware Design Reference Guide OK335xD