stm32---gpio

Publisher:ohp991养生的香菇Latest update time:2019-03-14 Source: eefocusKeywords:stm32  gpio Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

This program is a small entry-level program, equivalent to hello world in C language! I hope it will be helpful to you. I try to write this program as simple as possible!


The program is written using library functions and does not directly operate registers.


Library version STM32F10x_StdPeriph_Lib_V3.5.0, development environment MDK4.12, debugging tool is JLINK v8.0, chip STM32F103C8T6


Note: If you use the 3.5 library for development, the configuration of RCC is much simpler. The system calls the SystemInit() function by default to automatically initialize the clock. You only need to enable the corresponding GPIO port.



[cpp]  view plain copy

  1. #include "stm32f10x.h"  

  2.   

  3. //Define the GPIO structure  

  4. GPIO_InitTypeDef GPIO_InitStructure;  

  5.   

  6. //main function  

  7. int main()  

  8. {  

  9.       

  10.     // Enable GPIO clock    

  11.     RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB, ENABLE);  

  12.       

  13.     //GPIO structure configuration  

  14.     GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;     

  15.     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;  

  16.     GPIO_InitStructure.GPIO_Speed ​​= GPIO_Speed_50MHz;  

  17.       

  18.     //GPIO initialization  

  19.     GPIO_Init(GPIOB, &GPIO_InitStructure);    

  20.       

  21.     // Turn on the small light  

  22.     GPIO_SetBits(GPIOB, GPIO_Pin_5);  

  23.   

  24.     //Infinite loop  

  25.     while(1);  

  26. }  


 


Keywords:stm32  gpio Reference address:stm32---gpio

Previous article:STM32---Key learning
Next article:STM32F103 CAN communication filter settings

Recommended ReadingLatest update time:2024-11-16 20:51

Difference between STM32 core reset and system reset and program implementation
1. Preface Some systems allow reset, but have special requirements for peripherals: a certain IO state cannot be changed due to reset, a certain timer counter cannot be changed, etc. For example: System A controls the power of system B through an IO, and the power of system B is turned on only when this IO is set high
[Microcontroller]
stm32 startup process
In the current embedded application development process, C language has become the best choice for most occasions. In this way, the main function seems to be the starting point for granted - because C programs often start execution from the main function. But a question that is often overlooked is: how does the microc
[Microcontroller]
Analysis of TCP/IP protocol stack code UDP (STM32 platform)
1. Introduction to UDP UDP is a simple datagram-oriented transport layer protocol: each output operation of a process generates exactly one UDP datagram, which is assembled into an IP datagram to be sent. This is different from stream-oriented protocols such as TCP, where the entire data generated by the application
[Microcontroller]
Analysis of TCP/IP protocol stack code UDP (STM32 platform)
Limited edition 30% off! Mil STM32MP135 development board
When it comes to MCU , S MT32 comes to mind . As a model of the new generation of MPU , STM32MP1 has a very groundbreaking heterogeneous system architecture and is compatible with the dual advantages of MPU and MCU . It is entry-level, cost-effective, and can run Linux systems and applications . Feat
[Embedded]
Limited edition 30% off! Mil STM32MP135 development board
STM32_GPIO key input
/*  Name: STM32_GPIO key input  Note: This experiment is about the input function of GPIO. The basic idea is similar to that of 51 single-chip microcomputer.  Operate the corresponding IO port, but the difference is that for the independent key input experiment, the 51 microcontroller is  It is necessary to set the IO
[Microcontroller]
Interpretation of 8 configuration methods of STM32 IO port
8 configuration methods of STM32 IO port: (1) GPIO_Mode_AIN analog input  (2) GPIO_Mode_IN_FLOATING floating input (3) GPIO_Mode_IPD pull-down input (4) GPIO_Mode_IPU pull-up input (5) GPIO_Mode_Out_OD open-drain output (6) GPIO_Mode_Out_PP push-pull output (7) GPIO_Mode_AF_OD multiplexed open-drain output (8) GPIO_Mo
[Microcontroller]
Interpretation of 8 configuration methods of STM32 IO port
Things about STM32's independent watchdog
Why does the MCU have a watchdog? With this question, let's learn about the watchdog. Even the 51 microcontroller has a watchdog, which shows that this dog is very important to us. The purpose of the watchdog is to prevent the program from running wildly. The operation of the MCU program will be disturbed in differe
[Microcontroller]
Analysis and arrangement of Zhilin STM32 program source code 02
1. Analysis of STM32 clock configuration program 1、RCC      RCC stands for Reset and Clock Control. The main registers include control, configuration, interrupt, peripheral reset, peripheral clock enable, and reset status registers.      The core's working clock is SysClk, which has three sources: external clock H
[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号