chibiace 46 Posted November 14, 2011 Share Posted November 14, 2011 hi is it possible to set say BIT0-3 as on and 4-5 as off and 6-7 as on like: 11110011. such as this for arduino: DDRD = B11111110; // sets Arduino pins 1 to 7 as outputs, pin 0 as input from http://www.arduino.cc/en/Reference/PortManipulation thanks in advance. :clap: Quote Link to post Share on other sites
MattTheGeek 99 Posted November 14, 2011 Share Posted November 14, 2011 You can do that. PxOUT = 11110011; Quote Link to post Share on other sites
RobG 1,892 Posted November 14, 2011 Share Posted November 14, 2011 You can define binary type, see attached include file. Then you could do P1OUT = b11110011; binary.h.zip chibiace 1 Quote Link to post Share on other sites
SirZusa 34 Posted November 14, 2011 Share Posted November 14, 2011 you can also do PxOUT |= BIT1 | BIT2 | BIT3 | BIT4 | BIT5 | BIT6 | BIT7 | BIT8 or calculate the hexadecimal value out of your binary value and set it like PxOUT = 0xFF i relly dont understand why the compiler doesnt understand binary-format out of stock :crazy: especially programming MCU's this format is often used Quote Link to post Share on other sites
gordon 229 Posted November 14, 2011 Share Posted November 14, 2011 i relly dont understand why the compiler doesnt understand binary-format out of stock :crazy: especially programming MCU's this format is often used That question is best addressed to the ISO C Working Group . GCC does understand binary literals, though. Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.