Can I use the built in pull ups in the 16F876 for a 7 segment led?
How do I enable them in the options register?
Trying to do this with PBC and the Melabs bootloader.
Is it easier to do with PBP?
You can't use the build in pull-up's to drive leds! The pull-ups can only be enabled when the particular pin is in input mode. And the only purpose of these pull-ups is to keep the input in a known state (1) when the pin is left floating.
Use external resistors in series with the leds to drive them.
Clear Bit RBPU of OPTION_REG. (OPTION_REG is in bank1)
It's all explained in the datasheets
like this...
Code:
BCF STATUS, RP1
BSF STATUS, RP0 ;Goto bank1
BCF OPTION_REG, RBPU ;enable pullups (only works on pins in INPUT mode)
;code to go back to the desired bank here
Just a newbie question but, How about the PicBasic code. I don't know assembly.
I think I've got this figured out.
Code would be:
Poke Option_Reg, 128 ' enable PortB pullup resistors
Just a newbie question but, How about the PicBasic code. I don't know assembly.
I think I've got this figured out.
Code would be:
Poke Option_Reg, 128 ' enable PortB pullup resistors
well, i don't know PicBasic :? . But you just need to use the picbasic command to clear the RBPU bit in option_reg;
However, putting 128 in option_reg is not correct; this would SET the bit, you need to clear it. Secondly, you must find a command that only affects that single bit, writing 128 directly for example will set RBPU but will also clear all the other bits in option_reg wich is not good.
To enable the pull up resistors you should do the following:
Code:
OPTION_REG = $7f ' Enable PORTB pullups
:arrow: As you can see the OPTION_REG will have a 01111111, according to the OPTION_REG chart (attached) you can see that you enable the pull-ups and whatever else. If you want to change those parameters you can too.
I see. The same way all registers are accessed(TrisA,TrisB,etc...).
It makes sense now.
Does the compiler,PicBasic, recognize the following as the same?
Poke Option_reg,127
OR
Poke Option_reg,%01111111
OR
Poke Option_reg,$7f
If so I assume the first, decimal number, is the preffered way.
Thanks Exo, Andy and Ivancho for your help and patience.
:arrow: when indicating HEX there are some tricks to it I can't remember. It is something like you have to have 2 positions always, so to put hex A you will have to do $0A.
:!: You do not need to use the POKE comand, as long as you have the PBP. That is an old command that is still around.
But to answer you question, yes that is the same, but You are better off assgining the value to the register name like this