STM32 Experiment 2: IO Input

Publisher:平凡幸福Latest update time:2017-09-29 Source: eefocusKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

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;
            }
        }
    }
}


Keywords:STM32 Reference address:STM32 Experiment 2: IO Input

Previous article:STM32 Experiment 4: Key Interrupt
Next article:STM32 Experiment 1: IO Output

Recommended ReadingLatest update time:2024-11-16 12:49

About STM32 MCU transplantation FATFS
Friends who use single-chip microcomputers know that the ROM and RAM provided by single-chip microcomputers are generally small. Even if it is a 256KB flash and 64KB RAM like STM32. Once you need to store some files with a large amount of data, it is still not enough. Generally, large-capacity storage can be achieved
[Microcontroller]
STM32 FSMC Learning Notes (I)
FSMC Application Introduction FSMC stands for "static memory controller". STM32 can be connected to the pins of SRAM, ROM, PSRAM, Nor Flash and NandFlash memory through FSMC to exchange data. 1. Characteristics of FSMC: 1.  One of the major features of FSMC is that it supports asynchronous read and write operation
[Microcontroller]
STM32 FSMC Learning Notes (I)
STM32 registers and library functions
Earlier, I talked about a method of using direct register manipulation when talking about timers. Now I will give an example of LCD. void LCD_RESET(void) { LCD_RST_CLR; delay_ms(100); LCD_RST_SET; delay_ms(50); } The so-called reset is: pull low--delay--pull high. Generally, library functions are used, but you
[Microcontroller]
STM32 uses PWM + DMA to drive WS2812
Reference code: ----------------------------------WS2812B.c---------- -------------------------- #include "WS2812B.h" /* Buffer that holds one complete DMA transmission  *   * Ensure that this buffer is big enough to hold  * all data bytes that need to be sent  *   * The buffer size can be calculated as follows:  *
[Microcontroller]
STM32 startup file selection and macro definition
startup_stm32f10x_cl.s Interconnect devices, STM32F105xx, STM32F107xx startup_stm32f10x_hd.s Large capacity STM32F101xx, STM32F102xx, STM32F103xx startup_stm32f10x_hd_vl.s Large capacity STM32F100xx startup_stm32f10x_ld.s Small capacity STM32F101xx, STM32F102xx, STM32F103xx startup_stm32f10x_ld_vl.s Small capacity
[Microcontroller]
[STM32 motor square wave] Record 4——PWM output configuration
PWM generation principle:  The general timer can use the GPIO pin for pulse output. When configured as comparison output and PWM output function, the capture/compare register TIMx_CCR is used as the comparison function, which is referred to as the compare register below. Here is an example to illustrate the PWM output
[Microcontroller]
[STM32 motor square wave] Record 4——PWM output configuration
STM32-Serial Port Experiment Study Notes
USART1_IRQHandler(void) function: When a corresponding interrupt occurs on serial port 1, it will jump to the function execution. A small receiving protocol is designed here (not defined by the system): through this function, an array USART_RX_BUF and a receiving status register USART_RX_STA are used to manage the rec
[Microcontroller]
STM32-Serial Port Experiment Study Notes
STM32 Quick Learning 7-LED Flashing (TIM2 Query)
#include "stm32f10x_gpio.h" #include "stm32f10x_rcc.h" #include "stm32f10x_flash.h" #include "stm32f10x_tim.h" #include "misc.h" void RCC_Configuration(void); void GPIO_Configuration(void); void TIM_Configuration(void);   int main(void) {   RCC_Configuration();   GPIO_Configuration();   TIM_Con
[Microcontroller]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号