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.
Check your C-compiler. Many of them have a declaration syntax for bits. If they do then the statement is just something like
Code:
bit GIE INTCON.7
GIE = 0 ; /* Disable Interrupts */
...
GIE = 1 ; /* Enable Interrupts */
The declaration syntax is not part of the C language standard, but several compilers for processors that support bit addressing have invented such extensions. You do have to look carefully in the compiler documentation though.
Look for #pragma keyword=extended or something similar to see if there is a switch that enables or disables the extended language features.
If you think you've found something then write a short test program and look at the compiler output to see if it matches both your understanding and Nigel's example.
On real ports with a mixture of inputs and outputs you need to be careful with bsf and bcf instructions because in hardware they read all 8 bits of a port, modify the single bit, and write back all 8 bits. This can be problematic and there are warnings in the PIC data sheets.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.