0
\$\begingroup\$

http://ww1.microchip.com/downloads/en/DeviceDoc/70593d.pdf, here is the link for the data sheet it explains in section 9 as to configure COSC<2:0> of OSCCON register to one of the following. I am using primary oscillator with PLL it is represented as 011 as shown below. But when in code it is written as OSCCONbits.COSC!=0b011. I want know in value 0b011, I think that 011 represents the primary oscillator with PLL, but what is 0b which is attached as prefix to the value.

bit 14-12 COSC<2:0>: Current Oscillator Selection bits (read-only)

                111 = Fast RC oscillator (FRC) with Divide-by-N
                110 = Fast RC oscillator (FRC) with Divide-by-16
                101 = Low-Power RC oscillator (LPRC)
                100 = Secondary oscillator (Sosc)
                011 = Primary oscillator (XT, HS, EC) with PLL
                010 = Primary oscillator (XT, HS, EC)
               001 = Fast RC Oscillator (FRC) with Divide-by-N and PLL (FRCDIVN +PLL)
                000 = Fast RC oscillator (FRC)
\$\endgroup\$
  • \$\begingroup\$ Just a little note: the expression "OSCCONbits.COSC!=0b011" doesn't actually set the COSC bits to a value of 011. Its asking the question "are the COSC bits set to anything other than 011", returning a 1/0 (yes/no) result and leaving the COSC bits unchanged. \$\endgroup\$ – brhans Feb 5 '15 at 14:02
2
\$\begingroup\$

The value 0b011 represents the binary value 011, which equates to decimal 3.

The 0b signifies that the following digits are in base 2, or binary.

This notation was popular in a number of compilers, like GCC, and has since been adopted as part of the new C++14 standard.

It follows the same kind of syntax as using 0x... for hexadecimal.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.