curtis63

Set PinMode on 2 pins simultaneously

2 posts in this topic

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:

 

PinMode(14,OUTPUT);

PinMode(15,INPUT);

 

without the 2.5microsecond delay between the 2 calls above.

Share this post


Link to post
Share on other sites

Hi,

 

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?

 

Cheers,

energia likes this

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