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 ); } }
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
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- Xunwei i.MX6ULL Terminator Thread Basics Thread Termination and Recycling
- LED matrix display for dot pixel art
- The much-anticipated "China Chip" will be launched today. Are chip stocks still attractive?
- Driver and app
- Overcurrent protection circuit with self-locking
- LCD5110 driver for MSP430f5529
- TI DSP C6657 Learning - Compiling static library .lib
- tree Command
- What are the categories of edge computing devices?
- How to make a simple calculator using STM8L151K4