The most concise stm32 encoder program

Publisher:玉立风华Latest update time:2016-07-14 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
  1. #define ROTATE_A  PAin(2)
  2. #define ROTATE_B PAin(3)
  3. s16 DATA=0;
  4.  
  5. void EXTI2_IRQHandler(void)
  6. {
  7.   if (EXTI_GetITStatus(EXTI_Line2) != RESET)
  8.   {
  9.     if(ROTATE_A!=ROTATE_B)
  10.      {
  11.         DATA++;    
  12.      }
  13.         else DATA--;
  14.     EXTI_ClearITPendingBit(EXTI_Line2);
  15.   }
  16. }
  17.  
  18.  
  19. void main(void)
  20. {
  21.           SystemInit();
  22.           delay_init(72);
  23.           NVIC_Configuration();
  24.           KEY_Init();
  25.    while(1)
  26.   {
  27.        ;
  28.   }
  29. }




[Repost] The most concise stm32 encoder program - My Heart Will Go On - ARM Embedded Development [Repost] The most concise stm32 encoder program - My Heart Will Go On - ARM Embedded Development You can observe the picture. When it is clockwise, when A falls, A! = B; when it is counterclockwise, when A falls, A=B, so as to judge whether it is clockwise or counterclockwise. And it is simple to implement, only one interrupt is needed. In fact, I saw the idea somewhere else, and then copied it and modified it. If you encounter an encoder with AB output, you can refer to it. If you have any questions, you can raise them and learn from each other.
Keywords:stm32 Reference address:The most concise stm32 encoder program

Previous article:ARM Download Error
Next article:STM32F105 USB pin Vbus processing

Recommended ReadingLatest update time:2024-11-15 17:48

How to draw a schematic diagram of an STM32 microcontroller in a formal way
A common sense about STM32F1 series microcontrollers: From the above figure, we can see that according to the size of the Flash memory, STM32F1 is divided into 4 types, namely "low density", "medium density", "high density", "ultra-high density", and "interconnected type". The FLASH size of the STM32F103VET6 we use
[Microcontroller]
How to draw a schematic diagram of an STM32 microcontroller in a formal way
STM32 Notes External Interrupt GPIO
b) Initialization function definition: void EXTI_Configuration(void); //Define IO interrupt initialization function c) Initialization function call: EXTI_Configuration(); //IO interrupt initialization function call Simple application: d) Initialization function: void EXTI_Configuration(void) {   EXTI_InitTypeDef
[Microcontroller]
STM32 Novice Growth Record---System Tick Timer (systick) Application
1. Systick Introduction      Systick is just a timer, but it is placed in NVIC. Its main purpose is to provide a hardware interrupt (called tick interrupt) to the operating system. Tick interrupt? Here is a brief explanation. When the operating system is running, it will also have a "heartbeat". It will work according
[Microcontroller]
STM32 Novice Growth Record---System Tick Timer (systick) Application
STM32 Learning: External Interrupts
STM32 GPIO external interrupt summary 1. STM32 interrupt grouping:   Each GPIO of STM32 can be configured as an external interrupt trigger source, which is also the strength of STM32. STM32 divides many interrupt trigger sources into different groups according to the pin numbers. For example, PA0, PB0, PC0, PD0, PE0
[Microcontroller]
STM32 internal flash reading and writing program
/* Base address of the Flash sectors */   #define ADDR_FLASH_SECTOR_0     ((uint32_t)0x08000000) /* Base @ of Sector 0, 16 Kbytes */   #define ADDR_FLASH_SECTOR_1     ((uint32_t)0x08004000) /* Base @ of Sector 1, 16 Kbytes */   #define ADDR_FLASH_SECTOR_2     ((uint32_t)0x08008000) /* Base @ of Sector 2, 16 Kbytes
[Microcontroller]
Use STM32 to control the passive buzzer to play music (STM32_07)
1. Passive buzzer and active buzzer The active buzzer contains an oscillation source and will make a sound as long as it is powered on, but the frequency is fixed and the tone is single; the passive buzzer does not contain an oscillation source, and its internal structure is equivalent to an electromagnetic field sp
[Microcontroller]
Use STM32 to control the passive buzzer to play music (STM32_07)
STM32 Notes--SDIO (SD card reading)
To learn here, you must first understand the basic information of SD card: The SD card protocol has too many parts and is quite complicated. The recommended document is: "Simplified_Physical_Layer_Spec.pdf". Its main complexity lies in the numerous commands. There are 64 commands in total. You can check the do
[Microcontroller]
STM32 Notes--SDIO (SD card reading)
STM32 reads and writes flash to save user data
In actual projects, we may need to save some data and hope that the data can be used next time we start the system. Here we introduce how to use the internal flash of STM32 to save data. Here I use the STM32F103C8T6 chip for introduction. The flash size is 64K. In this example, 0x0800 0000~0x800 3000 is used as the bo
[Microcontroller]
STM32 reads and writes flash to save user data
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号