Sep 6, 2006 #1 V Vadivukkarasi.k Newbie level 2 Joined Sep 2, 2006 Messages 2 Helped 0 Reputation 0 Reaction score 0 Trophy points 1,281 Location chennai Activity points 1,289 micro controller how to set (example the 10th bit of MSB) in a micro controller of 16 bit
Sep 6, 2006 #2 lambtron Full Member level 5 Joined Nov 2, 2005 Messages 251 Helped 34 Reputation 68 Reaction score 8 Trophy points 1,298 Location Portland, OR Activity points 3,546 Re: micro controller Vadivukkarasi.k said: how to set (example the 10th bit of MSB) in a micro controller of 16 bit Click to expand... Here's a snippet of C code that will set bit 10 within a 16 bit value: Code: value |= (1 << 10); If the value is accessed by multiple threads then it might be a good idea to do it this way to ensure an atomic operation is performed: Code: DisableInterrupts(); value |= (1 << 10); EnableInterrupts();
Re: micro controller Vadivukkarasi.k said: how to set (example the 10th bit of MSB) in a micro controller of 16 bit Click to expand... Here's a snippet of C code that will set bit 10 within a 16 bit value: Code: value |= (1 << 10); If the value is accessed by multiple threads then it might be a good idea to do it this way to ensure an atomic operation is performed: Code: DisableInterrupts(); value |= (1 << 10); EnableInterrupts();