How can I determine RS08's ports Input or Output?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How can I determine RS08's ports Input or Output?

2,399 Views
muskut
Contributor I
Hi all,

How can I determine Rs08' ports input or output? Which registers do I have to use to assign for input or output. And when I want to read the datas of the port which registers do I have to control? If I have little codes or algorithm it will be good for me?

Thanks.
Labels (1)
0 Kudos
Reply
2 Replies

636 Views
mke_et
Contributor IV
If you are designing from scratch, they are pretty much whatever you want them to be, based on the chip variant.

One general hint though...

With all the parts, even other family parts like the '12', you'll find that a lot of times there's port enhancements. For example, PortA is commonly used as a 'data bus' if the chip supports an expanded mode. In one of my designs, I used PortA as a bi-directional databus...

So, if you do your own design from scratch, it's always a good idea to try to follow the subset of any of the ports for what they can do. It's not required, and sometimes you may find not practical, but by doing that, you find that you can keep your code base as a 'library' that can easily be modified in the future.

Other things and issues that may apply... I did a '12' design that uses I2C. It turned out I didn't want to order the variant of the part that had built in I2C so I did my own in software on the same pins. That way in the future if I now have routines that will drop in on a part with I2C or without it and I have flexibility in parts to use and configurations. Same with com ports, and control lines.

Mike
0 Kudos
Reply

636 Views
Santa
Contributor I
For al hardware related information always refer to the microcontrollers datasheet. For example in a HC908QTx the register ports are called PTA and PTB and the directiond registers are called DDRA and DDRB respectevly. An logic 1 in a DDRx register bit will put the respective PTx pin as an output. You can bit test that same bit to know if a pin is configured as input or output. To read/write information from/to a port use the PTx register.

If your are not using CW or any other advanced editing software you will probably will need to know the phisycal address of this registers to acces them. That can also be found in the datasheet. If using CW and using the Project Wizard, you will get a main.asm file that includes a file that contains all registers and bits definitions as named in the datasheet. That way you can acces a port using PTx.

Here is some code to show you the general idea:

....
; Include derivative-specific definitions
INCLUDE 'derivative.inc' ; THIS FILE CONTAINS ALL THE REGISTER/BIT DEFINITIONS

....

; SET THE INITIAL DIRECTIONS OF THE PORTS
mov #DDRA_INIC_VAL, DDRA
mov #DDRB_INIC_VAL, DDRB

; SET/CLEAR SOME PIN IN A PORT
bclr RING, PTB
bset RELE_OUT, PTA

Hope this helps!
0 Kudos
Reply