Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

bit testing problem in mikroC for AVR

Status
Not open for further replies.

Noman Yousaf

Full Member level 4
Joined
Nov 19, 2003
Messages
210
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,774
hi all
i am using mikro C for AVR.
how can i test or edit a bit in a variable int?like i have an 8 bit int "reg" and i want to make bit5 of "reg",hi. or i want to check the bit 5 is hi or low, for both cases, what i have to do? help please.
 

andre_luis

Super Moderator
Staff member
Joined
Nov 7, 2006
Messages
9,308
Helped
1,166
Reputation
2,351
Reaction score
1,152
Trophy points
1,403
Location
Brazil
Activity points
54,231
how can i test or edit a bit in a variable ?

Test bit 5:
Code:
if ( reg & 0b00100000 ) { //stuff here }
Edit bit 5:
Code:
reg |= 0b00100000 // Set bit
reg &= 0b11011111 // Clear bit
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top