STM32 uses TIMx_CH1 as Tx1F_ED counter clock

Publisher:小星星龙猫Latest update time:2017-02-19 Source: eefocusKeywords:sTM32  TIMx_CH1  Tx1F_ED Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Environment: iar arm 5.3 

stm32f103vbt6  

Use PA.8 to externally input a 10Mhz square wave. Data 4 can be obtained from the systick interrupt. 

4×5000 (prescale value)×1000 (tick interrupt time) = 20MHz 

It belongs to double-edge detection. One PA.8 pulse has 2 edges, so the clock is doubled.

Since TI1F_ED is used, its structure is as follows:


void RCC_Configuration( void )
{  /* Setup STM32 system (clock, PLL and Flash configuration) */
  SystemInit( );  
  /* Enable GPIOA, GPIOC and USART1 clock  */
  RCC_APB2PeriphClockCmd(
    RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC | RCC_APB2Periph_TIM1, ENABLE );
}

GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);void TIM1_Init( void )
{
  
  TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
  
  TIM_TimeBaseStructure.TIM_Period = 65535;
  TIM_TimeBaseStructure.TIM_Prescaler = 5000;
  TIM_TimeBaseStructure.TIM_ClockDivision = TIM_CKD_DIV1;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;
  TIM_TimeBaseInit( TIM1, &TIM_TimeBaseStructure );
  
  TIM_TIxExternalClockConfig( TIM1, TIM_TIxExternalCLK1Source_TI1ED,
    TIM_ICPolarity_Rising, 0 );
  
  TIM_Cmd( TIM1, ENABLE );
  
}int main( void )
{
  RCC_Configuration( );
  GPIO_Config( );
  TIM1_Init( );  /* Setup SysTick Timer for 1 msec interrupts  */
  if ( SysTick_Config( SystemFrequency / 1000 ) )
  {    /* Capture error */
    while ( 1 )
      ;
  }  
  while ( 1 )
  {
  }
}void SysTick_Handler( void )
{  static u32 i = 0;  
  if ( i == 0 )
  {
    i = 1;
    gusData = 0;
    TIM_SetCounter( TIM1, 0 );
    
  }  else
  {
    i = 0;
    gusData = TIM_GetCounter( TIM1 );
    
  }
  
}


 


Keywords:sTM32  TIMx_CH1  Tx1F_ED Reference address:STM32 uses TIMx_CH1 as Tx1F_ED counter clock

Previous article:Is the programming protocol of the SWD interface of STM32 public?
Next article:STM32 FSMC configuration SRAM

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

IAR stm32 warning:Label 'xxxxx' is defined pubweak in&
question: When building a project with IAR, REBUILD ALL will appear: lable xxxx is defined pubweak in a section implicitly declared root的警告 Solution: The solution is in the startup file used, such as startup_stm32f10x_hs.s (depending on which startup file you use). Add: NOROOT after the RECORDER appears. After recom
[Microcontroller]
IAR stm32 warning:Label 'xxxxx' is defined pubweak in&
STM32 CAN Learning
Recently, I have been doing CAN field bus experiments on the STM32 experimental board. I have only done serial communication on STC51 before. In comparison, I found that CAN bus is quite complicated. At the beginning, I knew that I was a novice. I only knew that CAN bus, like serial communication, 485 communication, an
[Microcontroller]
Brief Analysis of STM32 Official Firmware Library
The directory structure of the STM32 firmware library is shown in the figure below:             Our main concern is the Libraries folder. 1. _htmresc is the ST icon, Project is some examples and templates for reference and learning, Utilities is the routine of ST official evaluation board. 2. CMSIS (Cortex Mi
[Microcontroller]
STM32 memory architecture
I have been reading relevant materials for a while and I have written down what I have learned as a reminder. If there are any errors in this article, please point them out. I will be very grateful.   STM32F103ZET6 is an ARM-type microcontroller with Cortex-M3 core. It belongs to the high-density device of STM32 and h
[Microcontroller]
STM32 ISP Download
(1) First, adjust the startup method:         When downloading: Boot0 is set to 1 and Boot1 is set to 0, that is, boot from the system memory.         During operation: Boot0 is set to 0, Boot1 is set to 0, that is, booting from the user flash memory (User Falsh). (2) Open Flash Loader Demo, select the serial port
[Microcontroller]
STM32 ISP Download
STMicroelectronics is working with AWS and Microsoft to help STM32U5 enable more secure IoT development
STMicroelectronics is strengthening its collaboration with Amazon (AWS) and Microsoft to expand the Internet of Things. On AWS, ST provides a reference that makes it easier and more secure to connect IoT (Internet of Things) devices (STM32U5) to the AWS cloud. At the same time, STMicroelectronics is working with Micro
[Microcontroller]
STM32 Keil MDK uses JLink to simulate and debug keyboard keys online - detailed explanation with pictures and text
        It turns out that buttons can be debugged online using JLINK! I used to think that buttons can only be debugged by sending key values ​​through the serial port! This is great. Newbies who don't know how to do it should read on!         Note: When debugging a statement that requires a key to be press
[Microcontroller]
STM32 Keil MDK uses JLink to simulate and debug keyboard keys online - detailed explanation with pictures and text
STM32 hardware structure learning
stm32 hardware learning account ---- power supply Classification: 1. Working power 2. Backup domain power 3. ADC power supply reference power Working power supply 2-3.6v The backup domain power supply is used for RTC clock module and backup domain register preservation ADC power supply reference power supply
[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号