Jump to content

Set PinMode on 2 pins simultaneously

Recommended Posts

I'm writing my own i2c library and need to be able to simultaneously change PinMode on 2 pins.  One for SCL and one for SDA.  Is there a way to change PinMode on 2 pins simultaneously?


I want the behavior of the follwing:





without the 2.5microsecond delay between the 2 calls above.

Share this post

Link to post
Share on other sites



I've been following your bit-bang I2C efforts.

If you are making a custom version, perhaps using direct port I/O would be useful?


As follows:


P1DIR |= BIT7 + BIT6;       // make these outputs

P1OUT |= BIT7 + BIT6;     // make them simultaneously go hi

P1OUT &= ~(BIT7+BIT6);  //  ditto, but go low


The only thing is that it departs from energia statements.


I suspect you must have a scope / logic analyser or you wouldn't have known / measured the delay between the two PinMode statements you tried? 


Is this OK for your app?



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now