最近因项目需要用到了这块板子,遇到了这个问题,已经解决。因为板子没有复位脚,所以需要添加一段汇编语言,不然板子会直接锁死。以下是代码,仅供参考。 /* MAIN.C file */ #include "stm8l10x.h" #include "stm8l101_eval.h" #include "stm8l10x_gpio.h" #ifdef _COSMIC_ #define ASM _asm #endif #ifdef _IAR_ #define ASM asm #endif /* This delay should be added just after reset to have access to SWIM pin and to be able to reprogram the device after power on (otherwise the device will be locked) */ #define STARTUP_SWIM_DELAY_5S \ { \ ASM(" PUSHW X \n" \ " PUSH A \n" \ " LDW X, #0xFFFF \n" \ "loop1: LD A, #50 \n" \ \ "loop2: DEC A \n" \ " JRNE loop2 \n" \ \ " DECW X \n" \ " JRNE loop1 \n" \ \ " POP A \n" \ " POPW X " );\ } /* not connected pins as output low state (the best EMC immunity) (PA1, PA3, PA5, PB0, PB1, PB2, PB4, PC5, PC6, PD1, PD2, PD3, PD4, PD5, PD6, PD7)*/ #define CONFIG_UNUSED_PINS_STM8L001 \ { \ GPIOA->DDR |= GPIO_Pin_1 | GPIO_Pin_3 | GPIO_Pin_5; \ GPIOB->DDR |= GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_4; \ GPIOC->DDR |= GPIO_Pin_5 | GPIO_Pin_6; \ GPIOD->DDR |= GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | \ GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; \ } /* not connected pins as output low state (the best EMC immunity) (PA1, PA3, PA5, PB0, PB1, PB2, PB4, PC5, PC6, PD1, PD2, PD3, PD4, PD5, PD6, PD7)*/ #define CONFIG_UNUSED_PINS_STM8L001 \ { \ GPIOA->DDR |= GPIO_Pin_1 | GPIO_Pin_3 | GPIO_Pin_5; \ GPIOB->DDR |= GPIO_Pin_0 | GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_4; \ GPIOC->DDR |= GPIO_Pin_5 | GPIO_Pin_6; \ GPIOD->DDR |= GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | \ GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; \ } main() { /* -------------STM8L001 startup-------------- */ /* configure unbonded pins */ CONFIG_UNUSED_PINS_STM8L001; /* delay for SWIM connection: ~5seconds */ STARTUP_SWIM_DELAY_5S; /* ------------------------------------------- */ /* configure all STM8L001 pins as input with pull up */ GPIO_Init(GPIOA, GPIO_Pin_0, GPIO_Mode_In_PU_No_IT); // pin 1 GPIO_Init(GPIOA, GPIO_Pin_2, GPIO_Mode_In_PU_No_IT); // pin 2 GPIO_Init(GPIOD, GPIO_Pin_0, GPIO_Mode_In_PU_No_IT); // pin 5 GPIO_Init(GPIOB, GPIO_Pin_6, GPIO_Mode_In_PU_No_IT); // pin 6 GPIO_Init(GPIOB, GPIO_Pin_7, GPIO_Mode_In_PU_No_IT); // pin 7 GPIO_Init(GPIOC, GPIO_Pin_2, GPIO_Mode_In_PU_No_IT); // pin 8 }
所在话题
参与活动
-
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
网络 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16 -
滴滴押注社区团购,明确“投入不设上限,要做市场第一”
线下 2020-10-16