STM32 timer input capture points

Publisher:ByteWandererLatest update time:2017-10-02 Source: eefocusKeywords:stm32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The one using is stm32f103rct6.

I am currently writing a program that uses a single timer to capture 4-channel PWM waves. I have to change the detection edge in the interrupt function and manually calculate the PWM frequency and pulse width by manually recording the captured values.

There are many related programs on the Internet, but when I was writing them, I encountered a very insignificant problem for beginners, which caused the results to be wrong:

As shown in the figure, I am using TIM4_CH1. Because I saw that other structures were defined by themselves before use, I defined an object 'TIM4_Type' in the 'TIM_TypeDef' structure and then found that the result was wrong.

After careful analysis, I found that this structure already has an object instance in stm32f10x.h: TIM4. And the location of this TIM4 is exactly where those registers are located, and the object 'TIM4_Type' I defined myself is in the user memory area, so no matter how I operate 'TIM4_Type', I can't get the correct result.

Later, I looked at the official manual of V3.5 and found that those 'xxx_TypeDef' structures all have their own object declarations in stm32f10x.h and their own specific memory addresses. In other words, this type of structure does not need to be defined by yourself, while other types do not have specific memory addresses, so they need to be defined by themselves before they can be operated.



    Keywords:stm32 Reference address:STM32 timer input capture points

    Previous article:Detailed explanation of STM32's PWM output and calculation of frequency and pulse width (duty cycle)
    Next article:The JTAG port of the stm32f103 series chip is used as a normal IO

    Recommended ReadingLatest update time:2024-11-16 14:31

    [STM32 motor vector control] Record 6——FOC operation process
    Coordinate transformation theory: Coordinate transformation theory can reduce the complexity of the motor equations. Coordinate transformation is used to transform the stator and rotor variables into a rotating coordinate system whose rotation speed is the angular velocity ω. Assume fax, fbx, fcx are three-phase insta
    [Microcontroller]
    [STM32 motor vector control] Record 6——FOC operation process
    STM32 common GPIO operation function record
    STM32 reads a specific GPIOx bit as 1 or 0  1 /**  2 * @brief Reads the specified input port pin.  3 * @param GPIOx: where x can be (A..G) to select the GPIO peripheral.  4 * @param GPIO_Pin: specifies the port bit to read.  5 * This parameter can be GPIO_Pin_x where x can be (0..15).  6 * @retval The input port pi
    [Microcontroller]
    Discussion on AC and DC sampling of STM32 ADC
    cutting edge Regarding the STM32 sampling problem, I believe many people have encountered such a problem, whether it is about the underlying configuration of the ADC or the choice of the ADC sampling solution, or the ADC software and hardware filtering algorithm. Here, the blogger will extend the training questions he
    [Microcontroller]
    Discussion on AC and DC sampling of STM32 ADC
    STM32_External interrupt button control to light up the LED
    /*  Name: STM32_External interrupt button control to light up the LED  Note: For STM32, there are many types of interrupts. (In addition to external interrupts, there are also internal exceptions.) Each pin of its GPIO port can be used as an interrupt source for external interrupts. Its settings are also much more com
    [Microcontroller]
    About the STM32 serial port idle interrupt problem
    1. The idle interrupt is triggered when a byte of high level (idle) appears after receiving data. It does not mean that the idle interrupt will continue. To be precise, it should be a byte after the rising edge (stop bit). If it is always at a low level, the idle interrupt will not be triggered (it will trigger a brea
    [Microcontroller]
    Use JTAG to connect to STM32 SWD mode (STM32L011 as an example)
    Use JLINK's JTAG interface to connect to STM32's SWD mode I recently used STM32L011 to make products. This was my first time using SWD mode. Previously, I used the JTAG interface to download simulations. It was my first time using it, and I encountered many problems. Now I post the problems I encountered and the sol
    [Microcontroller]
    Use JTAG to connect to STM32 SWD mode (STM32L011 as an example)
    stm32 memory structure
    This is the onboard SRAM, which belongs to the external SRAM. The starting address is 0x68000000. I don’t understand why this address is used. This is the SRAM inside the core, which is divided into two parts: normal memory, starting at address 0x20000000, totaling 128KB, which can be accessed by any peripheral,
    [Microcontroller]
    stm32 memory structure
    Design of portable BMP picture decoding system based on STM32 processor
    In the application process of modern portable devices, it is often necessary to display some pictures in the system. Among various picture formats, BMP is the most representative one. BMP is an image file format that is independent of hardware devices and is widely used. It uses a bit-mapped storage format. In addi
    [Security Electronics]
    Design of portable BMP picture decoding system based on STM32 processor
    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号