STM32f030F4 20脚的MCU,GPIO不够,因此想把当晶振用的PF0 和PF1 也用了
看文档写的:
Using the HSE or LSE oscillator pins as GPIOs
When the HSE or LSE oscillator is switched OFF (default state after reset), the related oscillator pins can be used as normal GPIOs.
When the HSE or LSE oscillator is switched ON (by set
ting the HSEON or LSEON bit in the RCC_CSR register) the oscillator takes control of its associated pins and the GPIO configuration of these pins has no effect.
When the oscillator is configured in a user external clock mode, only the OSC_IN or OSC32_IN pin is reserved for clock input and the OSC_OUT or OSC32_OUT pin can still be used as normal GPIO.
已经:
#define PLL_SOURCE_HSI // HSI (~8MHz) used to clock the PLL, and the PLL is used as system clock source
//#define PLL_SOURCE_HSE // HSE (8MHz) used to clock the PLL, and the PLL is used as system clock source
//#define PLL_SOURCE_HSE_BYPASS // HSE bypassed with an external clock (8MHz, coming from ST-Link) used to clock
选择为内部RC振荡器,但是PF0 还是不能用,有哪位大虾知道否?
/* Configure PF.0 as PP output */
GPIO_InitStruct.GPIO_Pin = GPIO_Pin_0;
GPIO_InitStruct.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStruct.GPIO_OType = GPIO_OType_PP;
GPIO_InitStruct.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOF, &GPIO_InitStruct);
看一下GPIO.h,里面有IO复用映射void GPIO_PinAFConfig(GPIO_TypeDef* GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF);
我试过: //GPIO_PinAFConfig(GPIOF, GPIO_PinSource1, GPIO_AF_0);
发现不好使,F030的PDF中只描述了GPIOA,GPIOB的AFn的复用,没有讲到GPIOF,不知道怎么设置
我看了一下手册,应该是直接用就可以了。这2个引脚没有复用。
没有选择内部振荡器,结果管脚对地大约1.8V左右,选择内部RC振荡器后,管脚始终是低电平,f0的资料也太少了,要是f1早就搞定了
一周热门 更多>