不用的IO口可以悬空吗?

[复制链接]
2205|56
手机看帖
扫描二维码
随时随地手机跟帖
yszong| | 2018-10-11 19:01 | 显示全部楼层
可以的。

使用特权

评论回复
jiaxw| | 2018-10-11 19:04 | 显示全部楼层
自己设置一下高阻。

使用特权

评论回复
huangchui| | 2018-10-11 19:10 | 显示全部楼层
FPGA的设计一般都是需要设置高阻状态的。

使用特权

评论回复
zhenykun| | 2018-10-11 19:16 | 显示全部楼层


设置为输出,输出低电平
P1DIR = 0XFF;
P1OUT = 0X00;
忘了哪里看到的了,当然直接悬空也可以的

使用特权

评论回复
午夜粪车| | 2018-10-11 19:20 | 显示全部楼层
不是有内部上拉/下拉么?用软件方法试试

使用特权

评论回复
huangchui| | 2018-10-11 19:27 | 显示全部楼层

默认是输入,要是输入就不能“悬”了,悬着那就悬了。
要不设置为输出,要不就加个上拉!

使用特权

评论回复
jiajs| | 2018-10-11 19:31 | 显示全部楼层
一般都是做悬空处理的啊,特别是想征程低功耗设计的时候是很有必要的

使用特权

评论回复
wyjie| | 2018-10-11 19:34 | 显示全部楼层

不可以悬空吧。
可以设置成三态。

使用特权

评论回复
jiajs| | 2018-10-11 19:42 | 显示全部楼层

最好不要悬空,这样的引脚信号不一定。

使用特权

评论回复
huangchui| | 2018-10-11 19:48 | 显示全部楼层
你可以配置为高电平。

使用特权

评论回复
wuhany| | 2018-10-11 19:52 | 显示全部楼层
这个悬空引脚电压不一定怎么变化。

使用特权

评论回复
wyjie| | 2018-10-11 19:58 | 显示全部楼层

可以弄个上拉电阻弄成高电平。

使用特权

评论回复
zhenykun| | 2018-10-11 20:05 | 显示全部楼层
用不到也可以悬空,有问题。

使用特权

评论回复
wyjie| | 2018-10-11 20:20 | 显示全部楼层
最好能够设置到0或者1,不会影响单片机。

使用特权

评论回复
zhaoxqi| | 2018-10-11 20:20 | 显示全部楼层

uint32_t USTIMER0_init(void)
{
     // configure timer 0 for free run.
     // 32-bit unchained mode, timer3:4 /12 prescaler.

    // enable muxed pins as gpio outputs and disable all related interrupts.
     // would need to also setup the pinmux register to select the gpio
     // function of these pins in order to use as gpio.
//   TMR0->GPINT_GPEN = GPENO12 | GPENI12;
//  TMR0->GPDATA_GPDIR = GPDIRO12 | GPDIRI12;

   // stop and reset timer.
    TMR0->TGCR = 0x00000000;
    TMR0->TCR = 0x00000000;

   // disable interrupts and set emulation to free run.
    TMR0->INTCTLSTAT = 0;
    SETBIT(TMR0->EMUMGT, SOFT | FREE);

   // config timer0 in 32-bit unchained mode.
    // remove timer0 - 3:4 from reset.
    SETBIT(TMR0->TGCR, PRESCALER(TIMER_DIV - 1) | TIMMODE_32BIT_UNCHAINED /*| TIM34RS*/ );

   // init timer0 - 1:2 period....use full range of counter.
    TMR0->TIM34 = 0x00000000;
    TMR0->PRD34 = 0x00000000;
// TMR0->PRD34 = 0xFFFFFFFF;

   TMR0->TIM12 = 0x00000000;
    TMR0->PRD12 = 0x00000000;
    // start timer0 - 3:4.
// SETBIT(TMR0->TCR, ENAMODE34_CONT);

   return (ERR_NO_ERROR);
}


void USTIMER0_delay(uint32_t in_delay)
{
     uint32_t regData;
#if 0

    // stop the timer, clear int stat, and clear timer value.
     CLRBIT(TMR0->TGCR, TIM34RS);
     TMR0->TCR = 0x00000000;
     SETBIT(TMR0->INTCTLSTAT, PRDINTSTAT34);
     TMR0->TIM34 = 0x00000000;

    // setup compare time.

    TMR0->PRD34 = TICKS_PER_US * in_delay;

    // start timer1 - 3:4 to run once up to the period.
     SETBIT(TMR0->TCR, ENAMODE34_ONETIME);
     SETBIT(TMR0->TGCR, TIM34RS);

    // wait for the signal that we have hit our period.
     while (!CHKBIT(TMR0->INTCTLSTAT, PRDINTSTAT34));
#else
     // stop the timer, clear int stat, and clear timer value.
     CLRBIT(TMR0->TGCR, TIM12RS);
     TMR0->TCR = 0x00000000;
     SETBIT(TMR0->INTCTLSTAT, PRDINTSTAT12);
     TMR0->TIM12 = 0x00000000;

    // setup compare time.
     TMR0->PRD12 = TICKS_PER_US * in_delay;

    CLRBIT(TMR0->TCR,CLKSRC12);
     CLRBIT(TMR0->TCR,TIEN12);

    // start timer1 - 3:4 to run once up to the period.
     SETBIT(TMR0->TCR, ENAMODE12_ONETIME);
     SETBIT(TMR0->TGCR, TIM12RS);

    // wait for the signal that we have hit our period.
     while (!CHKBIT(TMR0->INTCTLSTAT, PRDINTSTAT12));
#endif
}

主函数

main()
{
     USTIMER0_init();
     printf("the timer0 test start\n" );
     USTIMER0_delay(100);
     printf("the timer0 test end\n");
}

使用特权

评论回复
quickman| | 2018-10-11 21:13 | 显示全部楼层
初始化会把所有IO口设置为输入状态

使用特权

评论回复
jstgotodo| | 2018-10-11 21:13 | 显示全部楼层
输入口不要悬空

使用特权

评论回复
iamaiqiyi| | 2018-10-11 21:13 | 显示全部楼层
如果输入口悬空,可能会导致输入电平处于非0和非1的中间状态

使用特权

评论回复
dzfansman| | 2018-10-11 21:13 | 显示全部楼层
一般的做法是通过一个电阻(例如10K或者1K)上拉到高电平或者下拉到低电平。

使用特权

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

本版积分规则

869

主题

13089

帖子

7

粉丝