We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
Dear all, I have a small keyboard in my application and I poll all the keys periodically. I can read all the key values with 2 bytes. Next, I check the bits of these bytes for specific keys. In my program, I have function (check_button()) which gets the byte value and the bit index of the required key. It extracts the bit using '>>' and '<<', and interprets the value.
for (button_index=0; button_index<8; button_index++) check_button(button_port_1, button_index); : : : void check_button(unsigned char buttons, unsigned char button_index) { get the bit using << and >> process it }
for (button_index=0; button_index<8; button_index++) { button_port_1 >>= 1; (I need to get the carry bit) check_button(carry_bit_taken_above, button_index); }
Andrew, Thanks for the reply. I know the bit data type. But, fastest way of accessing bits of a byte seems as using RRC and accessing carry flag. Am I wrong? Maybe I should change the question as follows: What is the fastest method to access any bit of a byte programmitically?