Home \ Help \ Search \ Login RSS

Welcome, Guest. Please Login

This forum is now READ-ONLY! Please visit http://forum.wiring.co/ for the new forum.

Wiring ForumBugsSoftware Bugs › problem with bitWrite?

Page Index Toggle Pages: 1
problem with bitWrite? (Read 7427 times)
10/15/10 at 15:11:36

roypardi   Offline
Junior Member
I Love YaBB 2!
Boston USA

Posts: 57
**
 
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);
} 




 
IP Logged
 
Reply #1 - 10/15/10 at 22:07:51

roypardi   Offline
Junior Member
I Love YaBB 2!
Boston USA

Posts: 57
**
 
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))
 

 
IP Logged
 
Reply #2 - 10/16/10 at 04:00:34

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
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.
 
IP Logged
 
Reply #3 - 10/16/10 at 08:40:04

roypardi   Offline
Junior Member
I Love YaBB 2!
Boston USA

Posts: 57
**
 
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
 
IP Logged
 
Reply #4 - 10/16/10 at 14:50:14

barragan   Offline
YaBB Administrator

Posts: 939
*****
 
great, : )
 
IP Logged
 
Page Index Toggle Pages: 1