Continue to Site

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
208
Helped
3
Reputation
6
Reaction score
2
Trophy points
1,298
Location
Lahore Pakistan
Activity points
1,763
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.
 

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.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top