Page 1 of 1

Enable weak-pulls 12F675

Posted: Tue Apr 28, 2009 2:48 pm
by medelec35
what is c code to enable weak-pull ups in option register, without changing any other bits of register.
I believe its a shift left command with a 1 and amount of places required i.e
option_reg (1<<7) or somthing like that
or is it best to mask unwanted changes i.e
option_reg = option_reg & 0b01111111
please bear in mind, my C knowledge is as weak as the pic pullups :lol:

Re: Enable weak-pulls 12F675

Posted: Tue Apr 28, 2009 2:52 pm
by Benj
Hello

The easiest option is probabl;y to use the set_bit funtion.

Here is some example code where 7 is the bit number of the register. Bits of registers are numbered 0 - 7.

set_bit(option_reg, 7);

If you wished to clear a bit then here is the function.

clear_bit(RegisterName, BitName Or BitNumber);

Re: Enable weak-pulls 12F675

Posted: Wed Apr 29, 2009 10:41 am
by medelec35
Thanks Ben,
That is a nice way of alterting option reg.