1. design requirements
EM-STM3210E Development Board has a LED lamp D1, write a program to light up the light.
2. hardware circuit connection
On the Development Board, D1 is connected to the PF6 pin on the STM32F103ZE chip, as shown in.
3. Software Programming
According to the task requirements, the program content mainly includes:
1. configure Reset and clock control (RCC) to enable the clock of the GPIOF port Module
2. Configure the PF6 pin of the GPIOF port (50 MHz, push-pull output)
3. Call the GPIO_WriteBit function of the STM32 standard Firmware Library to make the PF6 pin output a high level to light the LED lamp D1.
The entire project user only needs to implement the source code file: main. c. Other project files are provided by the MDK and STM32 standard firmware libraries.
The content of the main. c file is as follows:
[Cpp]
/**
**************************************** **************************************
* @ File main. c
* @ Author Max Liao
* @ Version
* @ Date 02-Novenber-2012
* @ Brief Main program body
**************************************** **************************************
*/
/* Includes ------------------------------------------------------------------*/
# Include "stm32f10x. h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
/* Private function prototypes -----------------------------------------------*/
Void RCC_Configuration (void );
Void GPIO_Configuration (void );
/* Private functions ---------------------------------------------------------*/
/**
* @ Brief Main program.
* @ Param None
* @ Retval None
*/
Int main (void)
{
RCC_Configuration ();
GPIO_Configuration ();
/* PF6 pin output high level, light the LED lamp D1 on the EM-STM3210E Development Board */
GPIO_WriteBit (GPIOF, GPIO_Pin_6, Bit_SET );
/* Infinite loop */
While (1 ){
}
}
Void RCC_Configuration (void)
{
RCC_APB2PeriphClockCmd (RCC_APB2Periph_GPIOF, ENABLE );
}
Void GPIO_Configuration (void)
{
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; // push the output
GPIO_Init (GPIOF, & GPIO_InitStructure );
}
[Cpp]
4. Program Running Effect