Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

to set a bit

Status
Not open for further replies.

srikanthind

New Member
i got a very basic doubt, i could not find all list of instructions, is there any instruction or datatype to set a particular pin in pic c (like BSF in assemble ), I tried with sbit, it didn't work.


could you give me the link where i can find the all instructions.

thank you
 
Depends on the bit.... If its an SFR its been defined ie.. PORTA has RA0, RA1, RA2...etc

Or you can specify PORTB.RB1 etc...

If you need to specify undefined bits in a byte.... Then you need to create a struct or union to access them

Code:
struct {
    unsigned mybit1:1;   // 1 bit
    unsigned mybit2:1;
    unsigned mybit3:1;
    unsigned mybits4:2;   // 2 bits
    unsigned mybits5:3;  // 3 bits
  };
} MYBYTEbits;
 
thank you
Depends on the bit.... If its an SFR its been defined ie.. PORTA has RA0, RA1, RA2...etc

Or you can specify PORTB.RB1 etc...

If you need to specify undefined bits in a byte.... Then you need to create a struct or union to access them

Code:
struct {
    unsigned mybit1:1;   // 1 bit
    unsigned mybit2:1;
    unsigned mybit3:1;
    unsigned mybits4:2;   // 2 bits
    unsigned mybits5:3;  // 3 bits
  };
} MYBYTEbits;
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top