STM32F030的PF0、PF1作为普通IO使用时无法正常输出高低电平
如下配置无法正常运行
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIO Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
/* Configure IO in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_SetBits(GPIOF, GPIO_Pin_1);
原因:
PF0,PF1在上电初始化过程中默认打开HSE时钟,这两个引脚作为晶振信号输入。
上电—》SystemInit()—》SetSysClock()
—》RCC-》CR |= ((uint32_t)RCC_CR_HSEON)/* Enable HSE */
解决办法:
1.在时钟初始化时增加RCC-》CR &= ~((uint32_t)RCC_CR_HSEON);
2.在PF0、PF1初始化时增加
GPIO_InitTypeDef GPIO_InitStructure;
/*STM32F030使用PF0 PF1,需要关闭HSE时钟*/
RCC-》CR &= ~((uint32_t)RCC_CR_HSEON);
/* GPIO Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
/* Configure IO in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_SetBits(GPIOF, GPIO_Pin_1);
STM32F0 强制设置TRACE功能,提示TRACE HW not present
Cortex-M0不支持Trace功能,因为是ARM V6结构,较老,没有ITM功能,所以无论你用Jlink,还是STLink,都不能用到Trace。

STM32F030的PF0、PF1作为普通IO使用时无法正常输出高低电平
如下配置无法正常运行
GPIO_InitTypeDef GPIO_InitStructure;
/* GPIO Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
/* Configure IO in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_SetBits(GPIOF, GPIO_Pin_1);
原因:
PF0,PF1在上电初始化过程中默认打开HSE时钟,这两个引脚作为晶振信号输入。
上电—》SystemInit()—》SetSysClock()
—》RCC-》CR |= ((uint32_t)RCC_CR_HSEON)/* Enable HSE */
解决办法:
1.在时钟初始化时增加RCC-》CR &= ~((uint32_t)RCC_CR_HSEON);
2.在PF0、PF1初始化时增加
GPIO_InitTypeDef GPIO_InitStructure;
/*STM32F030使用PF0 PF1,需要关闭HSE时钟*/
RCC-》CR &= ~((uint32_t)RCC_CR_HSEON);
/* GPIO Periph clock enable */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOF, ENABLE);
/* Configure IO in output pushpull mode */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_UP;
GPIO_Init(GPIOF, &GPIO_InitStructure);
GPIO_SetBits(GPIOF, GPIO_Pin_1);
STM32F0 强制设置TRACE功能,提示TRACE HW not present
Cortex-M0不支持Trace功能,因为是ARM V6结构,较老,没有ITM功能,所以无论你用Jlink,还是STLink,都不能用到Trace。

举报