Connection between a PSoC microcontroller with an outside world is achieved over input-output pins. Eight pin group which could be accessed simultaneously are parts of one port. Although port number differs from
the type of the microcontroller, write and read operations are done in the same way in any case. Port access registers are stored inside of register address space noted as PRT0DR, PRT1DR, PRT2DR, PRT3DR,
PRT4DR or PRT5
Writing to port
Writing value to PRTxDR initializes register which through init circuit drives the state of pins. Init circuit canvpass the signal from PRTxDR register directly (strong), over pull-up or pull-down resistors or through open
drain output. Beside that, there is a possibility to isolate value of register from pin state (Hi-Z).
Reading port
Reading value from address PRTxDR digital state of voltage on pins is stored to register A. In case that voltage is dictated by some external device, read value could differ from voltage on PRTxDR register.
Drive Mode
Selection of the way in which init register PRTxDR is connected to pins can be set inside of Device Editor or during runtime initializing registers PRTxDM2, PRTxDM1 and PRTxDM0. There is eight methods to initialize pins in total, which enables connection to different types of devices, with considerate smaller amount of external components. Pin work modes are defined according to the following table depending on contents of appropriate bit from registers DM2, DM1 and DM0.
Strong mode is used when it is needed to connect the state on PRTxDR register directly to pins. This way of connection is applied when pin is used as an input.
Analog Hi-Z mode is used when connecting analog signals, like AD converter input. In this case, all internal connections between PRTxDR register and pin are disconnected, so not to interfere with value of brought
voltage.
Pull-up or pull-down resistors are used when connecting with buttons or some other devices which demand this type of components. These resistors are defining the state on input when button is not pushed.
Open drain mode is used when it is needed to bring several devices to the same line, when it is needed to add one external pull-up or pull-down resistor. This mode is convenient for realization of a line which signals if
there has been a mistake to one of the microcontrollers. For example, when used pull-up resistor version when zero (error) occurs on any of output pins state of this line will be zero. Pins on PSoC microcontroller
allow user to generate interrupt on any pin, when signal changes, or on signal rising or falling edge.
No comments:
Post a Comment