Wiring Forum
http://wiring.org.co/cgi-bin/yabb/YaBB.pl
Bugs >> Software Bugs >> problem with bitWrite?
http://wiring.org.co/cgi-bin/yabb/YaBB.pl?num=1287155496

Message started by roypardi on 10/15/10 at 15:11:36

Title: problem with bitWrite?
Post by roypardi on 10/15/10 at 15:11:36
Haven't used bitWrite before and I am finding that it is not working. To test I used the example from the Reference in a sketch. The console output indicates no change in the value of x. This is with Wiring 0027 - OSX 10.5.8

Code:
void setup()
{
  Serial.begin(115200);

  ////----------------
  pinMode(48, OUTPUT);
  for (int i = 0; i < 3; i++) {
    digitalWrite(48, HIGH);
    delay(200);
    digitalWrite(48, LOW);
    delay(100);
  }
  digitalWrite(48, HIGH);
}

void loop()
{

  byte x = 33;

  Serial.print("before x: ");
  Serial.print(x, DEC);
  Serial.println(" ");
  // writes a 1 to the second bit bit of x, now x is 00100101 (37 in decimal)
  bitWrite(x, 2, 1);

  Serial.print(" after x: ");
  Serial.print(x, DEC);
  Serial.println(" ");

  delay(1000);
}




Title: Re: problem with bitWrite?
Post by roypardi on 10/15/10 at 22:07:51
Any help on this? I tried looking in the source and found the relevant code but couldn't see (or perhaps understand...) the issue.

The relevant code seems the same as in Wiring.h
[code c++]#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
[/code]

Title: Re: problem with bitWrite?
Post by barragan on 10/16/10 at 04:00:34
hi Roy, which platform are you using? could you please re-download and install 0027? your second post give me the hint you have installed one of the pre-release candidates for 0027, please download again and let me know.

Title: Re: problem with bitWrite?
Post by roypardi on 10/16/10 at 08:40:04
I'm on OSX 10.5.8 - the 0027 version I had was created Sept 21/2010. Just reinstalled 0027 and now bitWrite works.

Cool. Thanks for the quick reply!

--Roy

Title: Re: problem with bitWrite?
Post by barragan on 10/16/10 at 14:50:14
great, : )

Wiring Forum » Powered by YaBB 2.5 AE!
YaBB Forum Software © 2000-2010. All Rights Reserved.