EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling; EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure);
EXTI_InitTypeDef structure
EXTI_InitTypeDef¶¨ÒåÓÚÎļþ¡°stm32f10x_exti.h¡±£º
typedef struct { u32 EXTI_Line;
EXTIMode_TypeDef EXTI_Mode; EXTIrigger_TypeDef EXTI_Trigger; FunctionalState EXTI_LineCmd; }
EXTI_InitTypeDef;
EXTI_Line
EXTI_LineÑ¡ÔñÁË´ýʹÄÜ»òÕßʧÄܵÄÍⲿÏß·¡£ EXTI_Linex£ºÍⲿÖжÏÏßx£¨0--18£©
EXTI_Mode
EXTI_Mode£ºÉèÖÃÁ˱»Ê¹ÄÜÏß·µÄģʽ¡£
EXTI_Mode_Event£ºÉèÖÃEXTIÏß·ΪʼþÇëÇó EXTI_Mode_Interrupt£ºÉèÖÃEXTIÏß·ΪÖжÏÇëÇó
EXTI_Trigger
EXTI_Trigger£ºÉèÖÃÁ˱»Ê¹ÄÜÏß·µÄ´¥·¢±ßÑØ¡£
EXTI_Trigger_Falling£ºÉèÖÃÊäÈëÏ߷ϽµÑØΪÖжÏÇëÇó EXTI_Trigger_Rising£ºÉèÖÃÊäÈëÏß·ÉÏÉýÑØΪÖжÏÇëÇó
EXTI_Trigger_Rising_Falling£ºÉèÖÃÊäÈëÏß·ÉÏÉýÑغÍϽµÑØΪÖжÏÇëÇó
EXTI_LineCmd
EXTI_LineCmdÓÃÀ´¶¨ÒåÑ¡ÖÐÏß·µÄÐÂ״̬¡£Ëü¿ÉÒÔ±»ÉèΪENABLE»òÕßDISABLE¡£
3 º¯ÊýEXTI_StructInit
¹¦ÄÜÃèÊö£º°ÑEXTI_InitStructÖеÄÿһ¸ö²ÎÊý°´È±Ê¡ÖµÌîÈë Àý£º
EXTI_InitTypeDef EXTI_InitStructure; EXTI_StructInit(&EXTI_InitStructure);
EXTI_InitStructȱʡֵ
EXTI_Line£º EXTI_LineNone
EXTI_Mode£º EXTI_Mode_Interrupt EXTI_Trigger£º EXTI_Trigger_Falling EXTI_LineCmd£º DISABLE
4 º¯ÊýEXTI_GenerateSWInterrupt
¹¦ÄÜÃèÊö£º²úÉúÒ»¸öÈí¼þÖжÏ
9
Àý£º
EXTI_GenerateSWInterrupt(EXTI_Line6);
5 º¯ÊýEXTI_GetFlagStatus
¹¦ÄÜÃèÊö£º¼ì²éÖ¸¶¨µÄEXTIÏß·±ê־λÉèÖÃÓë·ñ Àý£º
FlagStatus EXTIStatus;
EXTIStatus = EXTI_GetFlagStatus(EXTI_Line8);
6 º¯ÊýEXTI_ClearFlag
¹¦ÄÜÃèÊö£ºÇå³ýEXTIÏß·¹ÒÆð±ê־λ Àý£º
EXTI_ClearFlag(EXTI_Line2);
7 º¯ÊýEXTI_GetITStatus
¹¦ÄÜÃèÊö£º¼ì²éÖ¸¶¨µÄEXTIÏß·´¥·¢ÇëÇó·¢ÉúÓë·ñ Àý£º
ITStatus EXTIStatus;
EXTIStatus = EXTI_GetITStatus(EXTI_Line8);
8 º¯ÊýEXTI_ClearITPendingBit
¹¦ÄÜÃèÊö£ºÇå³ýEXTIÏß·¹ÒÆðλ Àý£º
EXTI_ClearITpendingBit(EXTI_Line2);
Èý¡¢Í¨Óö¨Ê±Æ÷£¨TIM£©
TIM¼Ä´æÆ÷½á¹¹
TIM_TypeDeff£¬ÔÚÎļþ¡°stm32f10x_map.h¡±Öж¨ÒåÈçÏ£º
typedef struct {
vu16 CR1;
u16 RESERVED0; vu16 CR2;
u16 RESERVED1; vu16 SMCR;
u16 RESERVED2; vu16 DIER;
u16 RESERVED3;
10
vu16 SR;
u16 RESERVED4; vu16 EGR;
u16 RESERVED5; vu16 CCMR1; u16 RESERVED6; vu16 CCMR2; u16 RESERVED7; vu16 CCER;
u16 RESERVED8; vu16 CNT;
u16 RESERVED9; vu16 PSC;
u16 RESERVED10; vu16 ARR;
u16 RESERVED11[3]; vu16 CCR1;
u16 RESERVED12; vu16 CCR2;
u16 RESERVED13; vu16 CCR3;
u16 RESERVED14; vu16 CCR4;
u16 RESERVED15[3]; vu16 DCR;
u16 RESERVED16; vu16 DMAR;
u16 RESERVED17; }
TIM_TypeDef;
TIM¿âº¯Êý
1 º¯ÊýTIM_DeInit
¹¦ÄÜÃèÊö£º½«ÍâÉèTIMx¼Ä´æÆ÷ÖØÉèΪȱʡֵ Àý£º
TIM_DeInit(TIM2);
2 º¯ÊýTIM_TimeBaseInit
¹¦ÄÜÃèÊö£º¸ù¾ÝTIM_TimeBaseInitStructÖÐÖ¸¶¨µÄ²ÎÊý³õʼ»¯TIMxµÄʱ¼ä»ùÊýµ¥Î» Àý£º
TIM_TimeBaseInitTypeDef TIM_TimeBaseStructure; TIM_TimeBaseStructure.TIM_Period = 0xFFFF; TIM_TimeBaseStructure.TIM_Prescaler = 0xF;
TIM_TimeBaseStructure.TIM_ClockDivision = 0x0;
11
TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, & TIM_TimeBaseStructure);
TIM_TimeBaseInitTypeDef structure
TIM_TimeBaseInitTypeDef¶¨ÒåÓÚÎļþ¡°stm32f10x_tim.h¡±£º
typedef struct {
u16 TIM_Period; u16 TIM_Prescaler; u8 TIM_ClockDivision; u16 TIM_CounterMode; } TIM_TimeBaseInitTypeDef;
TIM_Period
TIM_PeriodÉèÖÃÁËÔÚÏÂÒ»¸ö¸üÐÂʼþ×°Èë»î¶¯µÄ×Ô¶¯ÖØ×°ÔؼĴæÆ÷ÖÜÆÚµÄÖµ¡£ËüµÄÈ¡Öµ±ØÐëÔÚ0x0000ºÍ0xFFFFÖ®¼ä¡£
TIM_Prescaler
TIM_PrescalerÉèÖÃÁËÓÃÀ´×÷ΪTIMxʱÖÓƵÂʳýÊýµÄÔ¤·ÖƵֵ¡£ËüµÄÈ¡Öµ±ØÐëÔÚ0x0000ºÍ0xFFFFÖ®¼ä¡£
TIM_ClockDivision
TIM_ClockDivisionÉèÖÃÁËʱÖӷָ TIM_CKD_DIV1£ºTDTS = Tck_tim TIM_CKD_DIV2£ºTDTS = 2Tck_tim TIM_CKD_DIV4£ºTDTS = 4Tck_tim
TIM_CounterMode
TIM_CounterModeÑ¡ÔñÁ˼ÆÊýÆ÷ģʽ¡£ TIM_CounterMode_Up£ºTIMÏòÉϼÆÊýģʽ TIM_CounterMode_Down£ºTIMÏòϼÆÊýģʽ
TIM_CounterMode_CenterAligned1£ºTIMÖÐÑë¶ÔÆëģʽ1¼ÆÊýģʽ TIM_CounterMode_CenterAligned2£ºTIMÖÐÑë¶ÔÆëģʽ2¼ÆÊýģʽ TIM_CounterMode_CenterAligned3£ºTIMÖÐÑë¶ÔÆëģʽ3¼ÆÊýģʽ
3 º¯ÊýTIM_OCInit
¹¦ÄÜÃèÊö£º¸ù¾ÝTIM_OCInitStructÖÐÖ¸¶¨µÄ²ÎÊý³õʼ»¯ÍâÉèTIMx Àý£º
TIM_OCInitTypeDef TIM_OCInitStructure;
TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_PWM1; TIM_OCInitStructure.TIM_Channel = TIM_Channel_1; TIM_OCInitStructure.TIM_Pulse = 0x3FFF;
TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High; TIM_OCInit(TIM2, & TIM_OCInitStructure);
TIM_OCInitStruct£º
12