/*! @function
************************************************** **********************************
º¯ÊýÃû :RCC_Configuration
¹¦ÄÜ :ʱÖÓÅäÖÃ
--- -------------------------------------------------- -----------------------------
²ÎÊý :ÎÞ
·µ»ØÖµ :ÎÞ
------------ -------------------------------------------------- -------------------
ʹÓõÄÈ«¾Ö±äÁ¿£ºÎÞ
---------------------- -------------------------------------------------- ---------
×÷Õß:
ʱ¼ä: 2012/10/17
************************** ****************************************************** *****/
static void RCC_Configuration(void)
{
ErrorStatus HSEStartUpStatus;
RCC_ClocksTypeDef RccClocks;
RCC_DeInit();
RCC_HSEConfig(RCC_HSE_ON);
HSEStartUpStatus = RCC_WaitForHSEStartUp();
if(HSEStartUpStatus == SUCCESS)
{
/* Ñ¡ÔñHCLK£¨AHB£©Ê±ÖÓԴΪSYSCLK 1·ÖƵ */
RCC_HCLKConfig(RCC_SYSCLK_Div1);
/* Ñ¡ÔñPCLK2ʱÖÓԴΪ HCLK£¨AHB£© 1·ÖƵ */
RCC_PCLK2Config(RCC_HCLK_Div1);
/* Ñ¡ÔñPCLK1ʱÖÓԴΪ HCLK£¨AHB£© 2·ÖƵ */
RCC_PCLK1Config(RCC_HCLK_Div2);
/* ÉèÖÃFLASHÑÓʱÖÜÆÚÊýΪ2 */
FLASH_SetLatency(FLASH_Latency_2);
/* ʹÄÜFLASHԤȡ»º´æ */
FLASH_PrefetchBufferCmd(FLASH_PrefetchBuffer_Enable);
/* Ñ¡ÔñËøÏà»·£¨PLL£©Ê±ÖÓԴΪHSE 1·ÖƵ£¬±¶ÆµÊýΪ9£¬ÔòPLLÊä³öƵÂÊΪ 8MHz * 9 = 72MHz */
RCC_PLLConfig(RCC_PLLSource_HSE_Div1, RCC_PLLMul_9);
/* ʹÄÜPLL */
RCC_PLLCmd(ENABLE);
/* µÈ´ýPLLÊä³öÎȶ¨ */
while(RCC_GetFlagStatus(RCC_FLAG_PLLRDY) == RESET);
/* Ñ¡ÔñSYSCLKʱÖÓԴΪPLL */
RCC_SYSCLKConfig(RCC_SYSCLKSource_PLLCLK);
/* µÈ´ýPLL³ÉΪSYSCLKʱÖÓÔ´ */
while(RCC_GetSYSCLKSource() != 0x08);
}
/* ÅäÖÃSysTick */
RCC_GetClocksFreq(&RccClocks);
//SysTick_Config(RccClocks.HCLK_Frequency / OS_TICKS_PER_SEC);
/* ´ò¿ªGPIOʱÖÓ */
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD| RCC_APB2Periph_GPIOE,
ENABLE);
RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);
}
/*! @function
********************************************************************************
º¯ÊýÃû :NVIC_Configuration
¹¦ÄÜ :ÖжϿØÖÆÆ÷ÅäÖÃ
----------------------------------------------------------------------------------
²ÎÊý :ÎÞ
·µ»ØÖµ :ÎÞ
---------------------------------------------------------------------------------
ʹÓõÄÈ«¾Ö±äÁ¿£ºÎÞ
----------------------------------------------------------------------------------
×÷Õß :
ʱ¼ä : 2012/10/17
*******************************************************************************/
static void NVIC_Configuration(void)
{
NVIC_InitTypeDef NVIC_InitStructure;
#ifdef VECT_TAB_RAM
/* Set the Vector Table base location at 0x20000000 */
NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
#else /* VECT_TAB_FLASH */
/* Set the Vector Table base location at 0x08000000 */
NVIC_SetVectorTable(NVIC_VectTab_FLASH , 0);
#endif
/* Configure one bit for preemption priority */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
/* Enable the USART1 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the USART2 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the USART3 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = USART3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the TIMER3 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM3_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
/* Enable the TIMER3 Interrupt */
NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQn;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
}
//72M timer2
//ÖжÏʱ¼ä£º£¨720*10£©/72000000=0.1Ms=10K
void Timer2_config() //ucosiiʱÖÓ
{
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure;
TIM_TimeBaseStructure.TIM_Prescaler = 360-1; //36M/360=100K HZ
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; //ÏòÉϼÆÊý
TIM_TimeBaseStructure.TIM_Period = 10; // ; //×°ÔØֵѡÔñ 10K
TIM_TimeBaseStructure.TIM_ClockDivision = 0;
//TIM_TimeBaseStructure.TIM_RepetitionCounter = 4;
TIM_TimeBaseInit(TIM2, &TIM_TimeBaseStructure);
TIM_ITConfig(TIM2,TIM_IT_Update|TIM_IT_Trigger,ENABLE);
TIM_Cmd(TIM2, ENABLE);
}
void TIM2_IRQHandler(void)
{
if (TIM_GetITStatus(TIM2, TIM_IT_Update) != RESET) //¼ì²éÖ¸¶¨µÄTIMÖжϷ¢ÉúÓë·ñ:TIM ÖжÏÔ´
{
if(Ledflg==0)
{
GPIO_SetBits(GPIOC, GPIO_Pin_6);
GPIO_SetBits(GPIOC, GPIO_Pin_7);
Ledflg=1;
}
else
{
GPIO_ResetBits(GPIOC, GPIO_Pin_6);
GPIO_ResetBits(GPIOC, GPIO_Pin_7);
Ledflg=0;
}
Ledcnt=0;
}
TIM_ClearITPendingBit(TIM2, TIM_IT_Update ); //Çå³ýTIMxµÄÖжϴý´¦Àíλ:TIM ÖжÏÔ´
}
Previous article:About the application configuration of stm32 timer
Next article:MCU drawing curve
Recommended ReadingLatest update time:2024-11-23 15:38
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- STMicroelectronics discloses its 2027-2028 financial model and path to achieve its 2030 goals
- 2024 China Automotive Charging and Battery Swapping Ecosystem Conference held in Taiyuan
- State-owned enterprises team up to invest in solid-state battery giant
- The evolution of electronic and electrical architecture is accelerating
- The first! National Automotive Chip Quality Inspection Center established
- BYD releases self-developed automotive chip using 4nm process, with a running score of up to 1.15 million
- GEODNET launches GEO-PULSE, a car GPS navigation device
- Should Chinese car companies develop their own high-computing chips?
- Infineon and Siemens combine embedded automotive software platform with microcontrollers to provide the necessary functions for next-generation SDVs
- Continental launches invisible biometric sensor display to monitor passengers' vital signs
- Qorvo Online Design Conference - Rapid Customization of Power ICs Using ActiveCiPS Technology
- How to avoid PCB electromagnetic interference in switching power supply design
- Industrial Module Technical Data
- Switching Power Supply Primer
- 12v to 24v booster circuit diagram, four 12v to 24v booster circuit diagrams, detailed explanation
- [Perf-V Review] + Button Control RGB_LED Color Change
- Research on Simulation of Spaceborne Synthetic Aperture Radar Data
- MSP430 Program Library --- 12864 LCD Program Library
- Car active safety devices fully explained
- Basic points of constant magnetic field