打印

PRT1GS的用法。

[复制链接]
1949|17
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
wazhzlp|  楼主 | 2012-12-24 14:55 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式
这是英文资料:
Writing this register high
enables the global bypass (BYP = 1 in Figure 6-1). If the
Drive mode is set to digital High Z (DM[2:0] = 010b), then
the pin is selected for global input (PIN drives to the Global
Input Bus). In non-High Z modes, the block is selected for
global output (the Global OutputBus drives to PIN), bypass-ing the data register value (assuming I2C Enable = 0).
If the PRTxGS register is written to zero, the global in/out
function is disabled for the pin and the pin reflects the value
of PRT_DR.
这里的意思是说当PRT1GS为高时,开全局bypass。此时如果驱动模式是高z的时候时,为全局输入。不是高z的时候,
为全局输出。后面的这句话bypass-ing the data register value (assuming I2C Enable = 0).是什么意思呢。
我想请教大家,这里的全局输入和配置图里的RO0有关系?

沙发
PSoC小子| | 2012-12-26 12:14 | 只看该作者
PRTxGS 是用来控制 IO 引脚是否连接到全局输入/输出总线的寄存器。使用该寄存器就可以将外部数字信号通过 IO 和全局输入总线引入芯片内部 (或者将内部数字信号通过全局输出总线和 IO 口引出。

以 P0[0] 为例,当 PRT0DR |= 0x01 被执行时,如果 P0[0] 当前的驱动模式为 HIGH-Z, 那么 P0[0] 被连接到全局输入总线,用作输入。 如果 P0[0] 当前的驱动模式为其他驱动模式,那么 P0[0] 被连接到全局输出总线,用作输出。 用作输出时, PRT0DR 的第 0 为(P0[0] 对应的位) 被旁路(bypass), 页就是说我们没有办法通过改变 PRT0DR 的0位来修改 P0[0] 的输出。

如果P0[0]被用作 I2C 引脚的话,P0[0]的当前输出只由 I2C 自己控制,用户也不可更改。

具体可以看一下下面 IO 口输出部分的内部结构图,然后就好理解了。



使用特权

评论回复
板凳
wazhzlp|  楼主 | 2012-12-26 14:00 | 只看该作者
PSoC小子 发表于 2012-12-26 12:14
PRTxGS 是用来控制 IO 引脚是否连接到全局输入/输出总线的寄存器。使用该寄存器就可以将外部数字信号通过 I ...

"用作输出时, PRT0DR 的第 0 为(P0[0] 对应的位) 被旁路(bypass), 页就是说我们没有办法通过改变 PRT0DR 的0位来修改 P0[0] 的输出。"这句话还是没有搞懂。请帮忙解答。

使用特权

评论回复
地板
PSoC小子| | 2012-12-26 14:24 | 只看该作者
这么说吧,如果一个 Pin 被连到了全局输出总线 (Global Out), 那么该 Pin 的输出状态完全由输出总线决定,用户无法更改。

例如一个PWM8 模块, PWM 的输出通过全局输出总线连到了 P0[0] 上, 那么 P0[0] 的输出状态完全由该模块决定。我们无法通过修改 PRTxDR 寄存器控制 P0[0] 输出高或者低。

使用特权

评论回复
5
wazhzlp|  楼主 | 2012-12-26 15:50 | 只看该作者
PSoC小子 发表于 2012-12-26 14:24
这么说吧,如果一个 Pin 被连到了全局输出总线 (Global Out), 那么该 Pin 的输出状态完全由输出总线决定 ...

懂了,也就是说为输出模式的时候没有发通过PRTODR来改变P0[0]的状态。

使用特权

评论回复
6
PSoC小子| | 2012-12-26 16:19 | 只看该作者
是的,从最上面我上传的框图里也可以看到。 当 BYP(bypass) 使能后, MUX 直接选通了 Global Output Bus, PRTxDR 被屏蔽了。

使用特权

评论回复
7
wazhzlp|  楼主 | 2012-12-26 16:39 | 只看该作者
PSoC小子 发表于 2012-12-26 16:19
是的,从最上面我上传的框图里也可以看到。 当 BYP(bypass) 使能后, MUX 直接选通了 Global Output Bus, ...

你帮我看看这个程序。我是想实现p0口控制p2口的led。
#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules


void main(void)
{
        int port0,port2;
        // M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts

       
        port0 = PRT0DR;
        //port0 &= 0xd0;
        port2 = port0;
        PRT2DR = port2;
       
        // Insert your main routine code here.
}
我不知道怎么去设置GPIO为输入和输出,是不是用PRTXDR  

使用特权

评论回复
8
PSoC小子| | 2012-12-26 16:52 | 只看该作者
设置 GPIO 的输入输出一个方法是在 Designer 里面对每个 Pin 的驱动状态进行设置。 另一个方法使用 PRTxDM0,PRTxDM1 和 PRTxDM2 设置 pin 脚的驱动模式。 一般情况下数字输入设为 HIGH-Z, 输出设为 Strong.
关于 IO 口的使用,可以参考 AN2094 - PSoC® 1 - Getting Started with GPIO
http://www.cypress.com/?rID=2900

使用特权

评论回复
9
wazhzlp|  楼主 | 2012-12-28 14:03 | 只看该作者
本帖最后由 wazhzlp 于 2012-12-28 16:23 编辑
PSoC小子 发表于 2012-12-26 16:52
设置 GPIO 的输入输出一个方法是在 Designer 里面对每个 Pin 的驱动状态进行设置。 另一个方法使用 PRTxDM0 ...

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules

使用特权

评论回复
10
PSoC小子| | 2012-12-28 16:01 | 只看该作者
使用 Designer 里面的管脚配置窗口和在程序里设置寄存器没有权限高低之分。管脚配置窗口只能决定芯片初始化时的引脚状态,如果你用些寄存器的方法修改,引脚状态就会改变。
我觉得根本问题可能不是这里。

使用特权

评论回复
11
wazhzlp|  楼主 | 2012-12-28 16:12 | 只看该作者
PSoC小子 发表于 2012-12-28 16:01
使用 Designer 里面的管脚配置窗口和在程序里设置寄存器没有权限高低之分。管脚配置窗口只能决定芯片初始化 ...

我想实现从PORT1输入不同的状态,从PORT2输出。
我的程序是这样:
void main(void)
{
   
    unsigned char port;
    // M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts

   
    port=PRT1DR;
    PRT2DR=port;
   
   
    // Insert your main routine code here.
}
其他的我在designer里已经设置好了。
PRT1DM0=0X00;
PRT1DM1=0XFF;
PRT1DM2=0X00;
  PRT1GS=0Xff;


PRT2DM0
PRT2DM0

使用特权

评论回复
12
wazhzlp|  楼主 | 2012-12-28 16:14 | 只看该作者
PRT2DM0=0XFF;
PRT2DM1=0X00;
PRT2DM2=0X00;

PRT2GS=0X00;

但是还是没有达到我的想法。在port1输入不同的IO状态。但是在port2是没有反应的。
请问我的问题出在哪里。

使用特权

评论回复
13
wazhzlp|  楼主 | 2012-12-28 16:23 | 只看该作者
PSoC小子 发表于 2012-12-26 16:52
设置 GPIO 的输入输出一个方法是在 Designer 里面对每个 Pin 的驱动状态进行设置。 另一个方法使用 PRTxDM0 ...

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules


void main(void)
{
   
    unsigned char port;
    // M8C_EnableGInt ; // Uncomment this line to enable Global Interrupts
PRT1DM0=0X00;
PRT1DM1=0XFF;
PRT1DM2=0X00;

PRT1GS=0Xff;
  
  
PRT2DM0=0XFF;
PRT2DM1=0X00;
PRT2DM2=0X00;

PRT2GS=0X00;
   
    port=PRT1DR;
    PRT2DR=port;
   
   
    // Insert your main routine code here.
}

a
我的程序是这样的,但是我在配置里没有改。他默认的端口配置是high z analog
然后我打开PSCConfigTBL.asm发现里面的代码如下:
LoadConfigTBL_pdproject25_Ordered:
;  Ordered Global Register values
    M8C_SetBank0
    mov    reg[00h], 00h        ; Port_0_Data register (PRT0DR)
    M8C_SetBank1
    mov    reg[00h], 00h        ; Port_0_DriveMode_0 register (PRT0DM0)
    mov    reg[01h], ffh        ; Port_0_DriveMode_1 register (PRT0DM1)
    M8C_SetBank0
    mov    reg[03h], ffh        ; Port_0_DriveMode_2 register (PRT0DM2)
    mov    reg[02h], 00h        ; Port_0_GlobalSelect register (PRT0GS)
    M8C_SetBank1
    mov    reg[02h], 00h        ; Port_0_IntCtrl_0 register (PRT0IC0)
    mov    reg[03h], 00h        ; Port_0_IntCtrl_1 register (PRT0IC1)
    M8C_SetBank0
    mov    reg[01h], 00h        ; Port_0_IntEn register (PRT0IE)
    mov    reg[04h], 00h        ; Port_1_Data register (PRT1DR)
    M8C_SetBank1
    mov    reg[04h], 00h        ; Port_1_DriveMode_0 register (PRT1DM0)
    mov    reg[05h], ffh        ; Port_1_DriveMode_1 register (PRT1DM1)
    M8C_SetBank0
    mov    reg[07h], ffh        ; Port_1_DriveMode_2 register (PRT1DM2)
    mov    reg[06h], 00h        ; Port_1_GlobalSelect register (PRT1GS)
    M8C_SetBank1
    mov    reg[06h], 00h        ; Port_1_IntCtrl_0 register (PRT1IC0)
    mov    reg[07h], 00h        ; Port_1_IntCtrl_1 register (PRT1IC1)
    M8C_SetBank0
    mov    reg[05h], 00h        ; Port_1_IntEn register (PRT1IE)
    mov    reg[08h], 00h        ; Port_2_Data register (PRT2DR)
    M8C_SetBank1
    mov    reg[08h], 00h        ; Port_2_DriveMode_0 register (PRT2DM0)
    mov    reg[09h], ffh        ; Port_2_DriveMode_1 register (PRT2DM1)
    M8C_SetBank0
    mov    reg[0bh], ffh        ; Port_2_DriveMode_2 register (PRT2DM2)
    mov    reg[0ah], 00h        ; Port_2_GlobalSelect register (PRT2GS)
    M8C_SetBank1
    mov    reg[0ah], 00h        ; Port_2_IntCtrl_0 register (PRT2IC0)
    mov    reg[0bh], 00h        ; Port_2_IntCtrl_1 register (PRT2IC1)
    M8C_SetBank0
    mov    reg[09h], 00h        ; Port_2_IntEn register (PRT2IE)
    M8C_SetBank0
    ret

上面表明模式还是在HIGH Z ANALOG .

使用特权

评论回复
14
waitingf| | 2012-12-29 12:21 | 只看该作者
进来学习的  哈哈哈

使用特权

评论回复
15
someonewho| | 2012-12-29 12:37 | 只看该作者
了解了解

使用特权

评论回复
16
justbybing| | 2012-12-29 12:39 | 只看该作者
对这方面了解的不多 真好学习一下

使用特权

评论回复
17
specialfrin| | 2012-12-29 13:13 | 只看该作者
路过 学习

使用特权

评论回复
18
someontime| | 2012-12-29 13:22 | 只看该作者
原来是这样啊

使用特权

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

本版积分规则

13

主题

51

帖子

1

粉丝