( Based on struggle stm32_v5 Development board )

1. Create configuration library file of project

2. to write main.c code
#include"stm32f10x.h" #define ON 1 #define OFF 0 #define DELAY_TIME 0x3FFFFF
enum { LED1 = 0, LED2, LED3, MAX_LED, }; typedef struct led_gpio_s { int num;
/* LED number */ GPIO_TypeDef *group; /* LED Used GPIO In which group : GPIOB or GPIOD */ uint16_t
pin; /* LED Used GPIO Which one in the group pin: GPIO_Pin_x */ } led_gpio_t; led_gpio_t
leds_gpio[MAX_LED] = { {LED1, GPIOB, GPIO_Pin_5}, /* LED1 Used GPB5 */ {LED2,
GPIOD, GPIO_Pin_6}, /* LED2 Used GPD6 */ {LED3, GPIOD, GPIO_Pin_3}, /* LED3 Used GPD3
*/ }; void init_led_gpio(void) { int i; GPIO_InitTypeDef GPIO_InitStructure; /*
Enable PB and PD group GPIO The clock of */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB |
RCC_APB2Periph_GPIOD , ENABLE); /* set up PB5(LED1), PD6(LED2), PD3(LED3) by GPIO
Output push immune mode , The turning speed of mouth line is 50MHz */ for(i=0; i<MAX_LED; i++) { /* set up PB5(LED1) by GPIO
Output push immune mode , The turning speed of mouth line is 50MHz */ GPIO_InitStructure.GPIO_Pin = leds_gpio[i].pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed
= GPIO_Speed_50MHz; GPIO_Init(leds_gpio[i].group, &GPIO_InitStructure); } }
void turn_led(int which, int cmd) { if(which<0 || which> MAX_LED ) return;
if(OFF == cmd) GPIO_ResetBits(leds_gpio[which].group, leds_gpio[which].pin);
else GPIO_SetBits(leds_gpio[which].group, leds_gpio[which].pin); } void
Delay(__IO uint32_t nCount) { for(; nCount != 0; nCount--) ; } int main(void) {
/* Initialize system clock */ SystemInit(); /* Initialize each LED Of GPIO Pin */ init_led_gpio(); while(1) {
/* hold LED1,LED2,LED3 Light up */ turn_led(LED1, ON); turn_led(LED2, ON); turn_led(LED3,
ON); Delay(DELAY_TIME); /* hold LED1,LED2,LED3 destroy */ turn_led(LED2, OFF);
turn_led(LED1, OFF); turn_led(LED3, OFF); Delay(DELAY_TIME); } }( Make relevant settings and compile )

3. to configure J-LINK debugging

Development board connection :

debugging :

4.LED Light flicker ( effect : The three lights flash at a certain frequency )

5. Troubleshooting

( One )

resolvent : Power up the development board

( Two )

resolvent :

Before troubleshooting : There is nothing below

After troubleshooting :

Technology
©2019-2020 Toolsou All rights reserved,
Java Swing JList: List box components Accurate mobile phone number capture , Big data of operators The difference between memory overflow and memory leak , Causes and Solutions Website mobile phone number capture method stay Vue Use in Web Worker3 species Python data structure ,13 Creation methods , This is the conclusion , Great ! What's the difference in server prices ? Basic definition and use of function ‘ To be continued SQL Server Database Glossary Chrome OS, For programmers and Windows What does it mean ? Internet Marketing