关于PB7问题

[复制链接]
3556|9
 楼主| rainbow99 发表于 2011-11-30 20:47 | 显示全部楼层 |阅读模式
我的板子PB7被用作外部看门狗,但我在网上看到有说这个口用作普通IO时,需要特殊操作,我试了半天没有搞定,请问谁有操作PB7的代码?谢谢
永远的不知 发表于 2011-11-30 20:51 | 显示全部楼层
1# rainbow99

PB7默认为NMI特殊管脚,设置为IO口,需要按如下方法操作。

    //
    // Convert the PB7/NMI pin into a GPIO pin.  This requires the use of the
    // GPIO lock since changing the state of the pin is otherwise disabled.
    //
    HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
    HWREG(GPIO_PORTB_BASE + GPIO_O_CR) = 0x80;

    //
    // Make PB7 an output.
    //
    GPIODirModeSet(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_DIR_MODE_OUT);
    GPIOPadConfigSet(GPIO_PORTB_BASE, GPIO_PIN_7, GPIO_STRENGTH_8MA,
                     GPIO_PIN_TYPE_STD);

    //
    // Clear the commit register, effectively locking access to registers
    // controlling the PB7 configuration.
    //
    HWREG(GPIO_PORTB_BASE + GPIO_O_LOCK) = GPIO_LOCK_KEY_DD;
    HWREG(GPIO_PORTB_BASE + GPIO_O_CR) = 0x00;
 楼主| rainbow99 发表于 2011-11-30 20:53 | 显示全部楼层
好的,我去试试。
 楼主| rainbow99 发表于 2011-11-30 21:17 | 显示全部楼层
可以了,多谢版主了。
tianm 发表于 2011-12-1 11:15 | 显示全部楼层
多看器件手册
tianyu01 发表于 2011-12-1 11:36 | 显示全部楼层
我也去试试
tianyu01 发表于 2011-12-1 11:36 | 显示全部楼层
sphinz 发表于 2011-12-1 13:01 | 显示全部楼层
我是当做NMI用了。
sqcumt123 发表于 2011-12-5 15:29 | 显示全部楼层
2楼提供了,我们占楼主光了,都好好学习一番
TI_MCU 发表于 2011-12-5 17:02 | 显示全部楼层
解释下,为了防止某些管脚功能被误操作,有些管脚需要解锁后才能修改功能,2楼的代码就是先解锁允许更改管脚功能
您需要登录后才可以回帖 登录 | 注册

本版积分规则

0

主题

54

帖子

1

粉丝
快速回复 在线客服 返回列表 返回顶部