Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob

BIT addressable variables

BIT addressable variables

Anonymous
Not applicable
Question: Is it possible to define and use bit addressable variable in C?

 

Answer:

PSoC does not have any bit addressable instructions. So, to operate on bits, bit masks should be used. For example, to set bit 0 of a variable

MyVariable |= 0x01;

To clear bit 0,

MyVariable &= ~0x01;

The above applies to ImageCraft compiler.  In HiTech you can do bit operations using "bit" type variables.  For example:

bit MyBitVariable;

MyVariable = 1;
MyVariable = 0;

HiTech actually translates the above instructions into setting and clearing bits in an 8 bit variable using bit masking.  For details on "bit" type variable refer the HiTech compiler user manual.

0 Likes
270 Views
Contributors