Home/Support/Support Forum/How to use gpio on RCM6700
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

How to use gpio on RCM6700

0 votes
asked Nov 10, 2014 in Rabbit Software by gitomjk New to the Community (4 points)
retagged Nov 9, 2014 by gitomjk

Please log in or register to answer this question.

3 Answers

+1 vote
 
Best answer
That didn't show up well. It should have been:

+5V to resistor to LED1 to PD4

+5V to resistor to LED2 to PD5
answered Nov 10, 2014 by trooper2 Veteran of the Digi Community (589 points)
selected Nov 12, 2014 by gitomjk
Thank You, trooper2, your answer helped me a lot.
The problem is, that I meed to get 32 pins for gpio. Now I know how to use ports: B,C,D,E (28 pins). How can I manage port A?
Many thanks to trooper2 and to other community members.
I try to write to PA, with WrPortI(PADR, NULL, 0xFF), but can't see any changes on pins.
Parallel Port A is configured byte-wise.  That means that all ports are either inputs or outputs and there cannot be a combination.  Port A is unique in this respect and the other ports can have inputs and outputs on the same port.

The WrPortI is used to write a value to a register and it needs three parameters.

    WrPortI(SPCR, &SPCRShadow, 0x84);

Parameter 1 - The register you wish to change
Parameter 2 - The shadow register of the register you wish to change
Parameter 3 - The value to write to the register

With any Port except Port A, you could also use BitWrPortI to configure a single bit on the port.  (Remember that Port A is configured byte-wise.)

    BitWrPortI(PGDR, &PGDRShadow, 1, 0);

Parameter 1 - The register you wish to change
Parameter 2 - The shadow register of the register you wish to change
Parameter 3 - The value to write to the register
Parameter 4 - Which bit you wish to change

Questions:
1) Does this mean that I cannot use any of the A ports as inputs?

This means you can use all the pins on Port A as inputs OR outputs, but not both.

2) If I wanted to use pins on port B as well or another port as outputs, what is the equivalent line command like the above that configures port B or another port as output?

Port A looks a little funny because the register is named Slave Port Control Register (SPCR). The other ports use a "Data Direction Register" to set the direction of the data.

Port A - No register to specifically control bits (Use SPCR for byte-wise)
Port B – PBDDR
Port C - PCDDR (Pins used for serial lines)
Port D - PDDDR
Port E - PEDDR

3) With the above line command in the code, can I intermix inputs and outputs on the same port? For example PA0 = output, PA3=input,….

You won't be able to use BitWrPortI to set up individual inputs and outputs on Port A as we discussed earlier.  When you want to set individual bits to inputs and outputs on a port that will allow that, you can use BitWrPortI to do it.

In the code here I have set the Port E Data Register (PEDR).  The value is "1" and the pin number is "0".  This code would continuously toggle the data bit:

while (1)
{
    BitWrPortI(PEDR, &PEDRShadow, 1, 0);  // Set PE0 to value 1
    BitWrPortI(PEDR, &PEDRShadow, 0, 0);  // Set PE0 to value 0
}

5) What does the 0x84 mean?

The value is a hexadecimal number and we use that system because it makes it easier to read the bits at a glance.  Take a look at this table:

Hex        Binary
0        0000
1        0001
2        0010
3        0011
4        0100
5        0101
6        0110
7        0111
8        1000
9        1001
A        1010
B        1011
C        1100
D        1101
E        1110
F        1111

Each hexadecimal digit is 4 bits and two digits gives us a full byte.

Some examples:
    0x00 = 0000 0000
    0x40 = 0100 0000
    0xAC = 1010 1100
    0x84 = 1000 0100

This statement WrPortI(SPCR, &SPCRShadow, 0x84) writes "1000 0100" to the bits of the SPCR register.

Looking at the Easy Reference Poster, I look at SPCR in the middle of the poster under SLAVE PORT to see how to set the bits.

Bit 7 - 1    (ignore smode pins)
Bit 6 - 0    (ignored for Write)
Bit 5 - 0    (ignored for Write)
Bit 4 - 0    (Disable slave port - port is byte-wide input)
Bit 3 - 0    (Disable slave port - port is byte-wide input)
Bit 2 - 0    (Disable slave port - port is byte-wide input)
Bit 1 - 0    (Priority 2 interrupt)
Bit 0 - 1    (Priority 2 interrupt)
+1 vote
The following is not specifically for the RCM6700 but it should show you how to proceed:

Note: This information is general to the Rabbit 4000 and certain pins may not be available on your product.

The first thing I want to do is to point you to our Rabbit 4000 Processor Easy Reference Poster:
http://ftp1.digi.com/support/documentation/0230125_b.pdf

The poster shows all the registers you need to set and makes it pretty easy to find what you need.

In the center of the poster is a description of the Parallel Ports and the registers associated with each one. For more specific details on the Parallel Ports, you will want to look here:
http://ftp1.digi.com/support/documentation/019-0152_L.pdf

Using the digital I/O on the Rabbit products isn’t difficult but is easier to do after looking at an example. Let’s step back for a moment and consider a simpler problem like lighting up two LEDs on Parallel Port D.

You could hook the LEDs directly up to PD4 and PD5 and use pull-up resistors with the LEDs like this.

+5 Volts
/\/\/\/\
LED1
PD4

+5 Volts
/\/\/\/\
LED2
PD5
(I would recommend a 330 Ohm or bigger resistor.)
With the LEDs hooked up as above, you should be able to use this code to light both LEDs.

/************************************************************/
#define ON 0
#define OFF 1

main()
{
WrPortI(PDDCR, &PDDCRShadow, 0); // make D driven high and low (see manual for details)
WrPortI(PDDDR, &PDDDRShadow, 0xFF); // make D output (see manual for details)
BitWrPortI(PDDR, &PDDRShadow, ON, 4); // PD4 becomes GND and LED lights up
BitWrPortI(PDDR, &PDDRShadow, ON, 5); // PD5 becomes GND and LED lights up
}
/************************************************************/

PDDCR = Port D Drive Control Register (Use this to set open drain)
PDDDR = Port D Data Direction Register (Use this to define input or output)
PDDR = Port D Data Register (Use this to actually send the data)

This provides a very basic example of the digital I/O of a Rabbit microprocessor.

Full details on Parallel Port D (and more) can be found in the Rabbit 4000 Microprocessor User’s Manual here:
http://ftp1.digi.com/support/documentation/019-0152_L.pdf

After looking over this example, you should be able to do more complicated things.
answered Nov 10, 2014 by trooper2 Veteran of the Digi Community (589 points)
+1 vote
Hello Gitomjk, you can use port A (the programming port) when you put the unit in run mode. This is used for the programming port and will not when when debugging.
answered Nov 11, 2014 by MargaretK Veteran of the Digi Community (545 points)
Hello Trooper and Margaret,
I figured out, how to use all the parallel ports finally, and the app works! Now, I need to get back to debug mode( so I can see console from my dynamic C IDE).
I changed back my SSPCR settings, but it didn't help.

Thank you ,again,
Regards,
Evgeniy
...