STM实验程序代码

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验1G P I O

#include "stm32f10x.h"

#include "delay.h"

//#include "sys.h"

#include "stm32f10x_exti.h"

//QHKJ TEB-CM5000实验箱STM32实验1

//固件库V3.5工程模板

//QHKJ

GPIO_InitTypeDef GPIO_InitStructure;

EXTI_InitTypeDef EXTI_InitStructure;

/* Private function prototypes -----------------------------------------------*/ void RCC_Configuration(void);

void NVIC_Configuration(void);

void GPIO_Configuration(void);

/* Private functions ---------------------------------------------------------*/

/****************************************************************************** *

* Function Name : main

* Description : Main program.

* Input : None

* Output : None

* Return : None

******************************************************************************* /

int main(void)

{

/* Configure the system clocks */

// RCC_Configuration();

// SysTick_Configuration();

delay_init();

/* NVIC Configuration */

NVIC_Configuration();

/* Configure the GPIO ports */

GPIO_Configuration();

/* Connect EXTI Line9 to PA.9 */

GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource9);

/* Configure EXTI Line8 to generate an interrupt on falling edge */

EXTI_InitStructure.EXTI_Line = EXTI_Line9;

EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;

EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;

EXTI_InitStructure.EXTI_LineCmd = ENABLE; EXTI_Init(&EXTI_InitStructure);

for(;;)

{

GPIO_Write(GPIOF, 0xf80f);

delay_ms(100);

GPIO_Write(GPIOF, 0xf817);

delay_ms(100);

GPIO_Write(GPIOF, 0xf827);

delay_ms(100);

GPIO_Write(GPIOF, 0xf847);

delay_ms(100);

GPIO_Write(GPIOF, 0xf887);

delay_ms(100);

GPIO_Write(GPIOF, 0x8907);

delay_ms(100);

GPIO_Write(GPIOF, 0xfa07);

delay_ms(100);

GPIO_Write(GPIOF, 0xfc07);

delay_ms(100);

}

}

*

* Function Name : NVIC_Configuration

* Description : Configures Vector Table base location.

* Input : None

* Output : None

* Return : None

******************************************************************************* /

void NVIC_Configuration(void)

{

NVIC_InitTypeDef NVIC_InitStructure;

/* Configure one bit for preemption priority */

NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);

/* Enable the EXTI9_5 Interrupt */

// NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQChannel;

NVIC_InitStructure.NVIC_IRQChannel = EXTI9_5_IRQn;

NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;

NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;

NVIC_Init(&NVIC_InitStructure);

}

相关文档
最新文档