打印
[STM32F1]

stm32103如果不用32k晶振,那引脚是悬空还是接地?

[复制链接]
6639|12
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
c555|  楼主 | 2016-1-8 19:01 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
电路中用不到32k晶振,就没必要接了,那么空闲的这两个引脚应该怎么处理好呢?
沙发
643757107| | 2016-1-8 20:20 | 只看该作者
悬空处理,目前官方的开发板有的没有接那个晶振就是悬空处理,是不完全正确的,需要根据官方手册给的功能来设置。

使用特权

评论回复
板凳
643757107| | 2016-1-8 20:21 | 只看该作者
如果使用内部RC振荡器而不使用外部晶振,请按照下面方法处理:
1)对于100脚或144脚的产品,OSC_IN应接地,OSC_OUT应悬空。
2)对于少于100脚的产品,有2种接法:
  2.1)OSC_IN和OSC_OUT分别通过10K电阻接地。此方法可提高EMC性能。
  2.2)分别重映射OSC_IN和OSC_OUT至PD0和PD1,再配置PD0和PD1为推挽输出并输出'0'。此方法可以减小功耗并(相对上面2.1)节省2个外部电阻。
--------------------------------------------------------------------------------
以下是在ST英文网站FAQ上抄下的详细解释:
    1)  In 100 and 144 packages,  the OSC_IN /OSC_Out pins are a dedicated pins for HSE and mapped respectively on pins 12, 13 and pins 23, 24 for LQFP packages. Although, for BGA 100 and BGA 144 packages, they are mapped respectively on pins C1,D1 and pins D1,E1. In this case the recommended configuration is:
OSC_In pin must be connected to ground as it is always an input pin
OSC_Out must be left not connected as it is always an output pin.

     2)  In LQFP48 and LQFP64 packages,  the OSC_IN/OSC_Out pins are mapped on pins 5,6 whereas in the VFQFPN36 package they are mapped on pins 2,3. However the PD0 and PD1 functionality can be remapped by software on these pins.  There are two possible configurations:
Hardware configuration: Connect the OSC_IN/OSC_Out pins to ground through a 10K pull down resistors.
Software configuration: First, the OSC_IN/OSC_Out pins are left not connected on PCB layout. Then, remap the PD0 and PD1 functionality by software on these pins and configure the PD0/PD1 to Output push-pull forced to 0 logic level(Data Register = 0). This will maintain those I/Os to a fixed level minimizing Noise and external stress on these pins.

     The software configuration is recommended to reduce the power consumption and saves cost by avoiding the use of external pull down resistors as the I/O is already connected to the ground internally. Whereas the hardware configuration is recommended to increase the EMC performance.

STM32中如何使用PC14和PC15
     在STM32的数据手册的管脚分配图中可以看到:PC14与OSC32_IN公用一个引脚,PC15与OSC32_OUT公用一个引脚,它们的使用方法如下:
当LSE(低速外部时钟信号)开启时,这两个公用管脚的功能是OSC32_IN和OSC32_OUT。
当LSE(低速外部时钟信号)关闭时这两个公用管脚的功能是PC14和PC15。
    备用区域控制寄存器(RCC_BDCR)的LSEON用于控制LSE的开启或关闭。关于这个寄存器的用法请参看《STM3210x技术参考手册》。
--------------------------------------------------------------------------------
作为GPIO输出的配置过程:
(1).使能GPIOC时钟
  RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);

(2).配置GPIOC
   GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15;
   GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
   GPIO_Init(GPIOC, &GPIO_InitStructure);
(3).然后写高写低
  GPIO_WriteBit(GPIOC, GPIO_Pin_14, Bit_SET);
   GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_SET);
   GPIO_WriteBit(GPIOC, GPIO_Pin_14, Bit_RESET);
   GPIO_WriteBit(GPIOC, GPIO_Pin_15, Bit_RESET);
     以上代码跑在两个板子上,一个是backup区域里的RCC_DBCR的LSEON为0,即LSE关闭,以上(3)的操作从示波器上看到了电平相应变换;另外一个板子,backup区域里的RCC_DBCR的LSEON为1,即LSE打开,则以上(3)的操作从示波器上看到无效。
--------------------------------------------------------------------------------
作为GPIO输入的配置过程:
  只是把以上的(2)稍微改一下,(3)就不用了
  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_14 | GPIO_Pin_15;
   GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
   GPIO_Init(GPIOC, &GPIO_InitStructure);
   外部连接为:在PC14引脚焊了一个电阻,电阻另一端通过跳线在上拉到3.3V和下拉到地的两种情况下,读出GPIOC_IDR.14分别为"1"和"0"。
--------------------------------------------------------------------------------
作为外部中断输入的配置过程:
1.时钟使能
// + osc32_in/out --> pc14/15
   RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC |RCC_APB2Periph_AFIO, ENABLE);
   注意要使能AFIO的时钟哦
2.中断配置

  // + for EXTI on PC.14 at falling edge

   NVIC_PriorityGroupConfig(NVIC_PriorityGroup_1);
   NVIC_InitStructure.NVIC_IRQChannel = EXTI15_10_IRQChannel;
   NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
   NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
   NVIC_Init(&NVIC_InitStructure);
3. GPIO配置同上
4. EXTI配置
// + for PC14 EXTI @ falling edge
   GPIO_EXTILineConfig(GPIO_PortSourceGPIOC, GPIO_PinSource14);
   EXTI_InitStructure.EXTI_Line = EXTI_Line14;
   EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
   EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
   EXTI_InitStructure.EXTI_LineCmd = ENABLE;
   EXTI_Init(&EXTI_InitStructure);
5. 中断处理ISR
void EXTI15_10_IRQHandler(void)
{
   if(EXTI_GetITStatus(EXTI_Line14) != RESET)
   {

     EXTI_ClearITPendingBit(EXTI_Line14);
   }
}
     在中断处设置断点,只要按下key,就进入中断,跑出中断,再按key,再次进入,屡试不爽,试验完成~~~

使用特权

评论回复
地板
yiyigirl2014| | 2016-1-8 21:18 | 只看该作者
The software configuration is recommended to reduce the power consumption and saves cost by avoiding the use of external pull down resistors as the I/O is already connected to the ground internally. Whereas the hardware configuration is recommended to increase the EMC performance.

使用特权

评论回复
5
Snow7| | 2016-1-8 22:08 | 只看该作者
悬空也行,最好是OSC_IN和OSC_OUT分别通过10K电阻接地

使用特权

评论回复
6
ranqingfa| | 2016-1-9 19:15 | 只看该作者
643757107 发表于 2016-1-8 20:21
如果使用内部RC振荡器而不使用外部晶振,请按照下面方法处理:
1)对于100脚或144脚的产品,OSC_IN应接地, ...

讲解很认真,学习了,一直都是全部悬空:lol

使用特权

评论回复
7
lwsn| | 2016-1-9 22:21 | 只看该作者
楼长的详细,OSC_IN应接地,OSC_OUT应悬空

使用特权

评论回复
8
米尔豪斯| | 2016-1-10 15:31 | 只看该作者
STM32的数据手册上有提到,对于不用的GPIO应该全部10K电阻到地,或上拉。

使用特权

评论回复
9
desertsailor| | 2016-1-10 17:05 | 只看该作者
不使能RTC,当做普通IO处理就行了。

使用特权

评论回复
10
643757107| | 2016-1-19 12:02 | 只看该作者
OSC_IN应接地,OSC_OUT应悬空

使用特权

评论回复
11
kevinelectric| | 2016-2-29 23:51 | 只看该作者
接地或者上拉之后,不用的引脚是都交给软件去处理了吗?

使用特权

评论回复
12
sflower| | 2016-3-1 08:59 | 只看该作者
我在使用中是悬空的没有问题

使用特权

评论回复
13
wgmlove2014| | 2016-3-31 09:37 | 只看该作者
搂主提出的问题是问OSC32_IN和OSC32_OUT(PC14,PC15)两个引脚的处理问题,而这里面有的工程师回答的却是OSC_IN和OSC_OUT引脚处理的。回答得很详细,我表示赞同,可是,有点答非所问了。还是请各位高工赐教。

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

264

主题

556

帖子

3

粉丝