Can someone please help me to understand the bit_test function because I can't understand it? I want to create a push button control and after 5 seconds that the user keep the button pressed, an action will be executed. The description that I found on the CCS C manual is this:
Tests the specified bit (0-7,0-15 or 0-31) in the given variable. The least significant bit is 0. This function is much more efficient than, but otherwise similar to: ((var & (1<<bit)) != 0)
Thanks for your help. I am assuming that the other similar function like bit_clear(), bit_set() use the similar structure.
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
Posted: Mon Sep 05, 2011 6:10 pm
In any variable or register that can be defined with the #DEFINE statement - this lets you logically test each bit. If it is a '1' the bit_test() of that bit number is true , else it is false.
So if you were to do this for say the 16f887:
Code:
#DEFINE PORTB 0x06
bit_test(portb,0); // would return a true or false
// for second arguments of 0-7
// based on the true or false state of logic voltages on the pins of portb
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum