Main Site Documentation

Set multiple pins at once?


#1

On an Arduino I can use a register to set multiple pins at once, ie:


	// Copy the current state of the register holding the feature pins.

	byte b = PORTD;

	// Set feature bits.

	if (x) bitSet (b,2);
	if (y) bitSet (b,3);
	if (z) bitSet (b,4);

	// Copy the updated byte to the port register to set all of the pins active
	// at the same time.

	PORTD = b;

Is there any similar feature available through MF or the GHI libraries?

Ron.


#2

AFAIK, this is not possible right now.

Please look at this post for some info. on what may come in future :

http://tinyclr.com/forum/1/1421/#/1/


#3

You kinda answered your own question :slight_smile: You can use register access to set multiple pins simultaneously. GHI libraries include “Register” class.

GHI is looking into adding parallel support but that will still not set pins simultaneously. why? Because we want it to work on any pins and the pins may not be on the same port.

You didn’t say what you are trying to do so we can help you better.


#4

Great, I found the documentation for the Register class. To help later readers it is in the GHIElectronics.NETMF.Hardware.LowLevel namespace at http://ghielectronics.com/downloads/NETMF/Library%20Documentation/html/be700fb0-683f-e830-99f8-bc6dfad09569.htm.

Now, where may I find port/register documentation that maps to the IO pins?

The reason I’m doing this is because there are co-dependencies between the pins, where an action on one may be required to occur at the same time as an action on another. I’m a little paranoid about the Garbage Collector, and afraid that setting the pins individually MAY result in a scenario where one is set, the GC kicks in, and the other is not set until some time later.


#5

Depending on your device, you need to check the processor manual. For example, on domino it is LPC2388


#6

Thank you :slight_smile: Really appreciate the fast replies.

Now all I need is for my Tinkerer Kit to be shipped and I can test this code for real.


#7

I use Register class in my LCD driver.

http://www.fezzer.com/project/60/24-tft-lcd-screen-module/

Tested it on Panda.