Yes of course. GCB does a lot of things, but if you don't see a particular function in the help file, it is likely not addressed. Take a stroll to the GPIO/Additional Pin Functions section of your device data sheet, to get info on the WPU register.
So this comes under the heading of manual settings. On more complicated projects, this can happen a lot. And, familiarity with data sheet and the device.dat file becomes necessary. Set the pin direction to input, and then enable by setting the weak pullup bit, WPU1=1, WPU2=1, or?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I checked the data sheet for the pic12f1840 and there is the WPUA: WEAK PULL-UP PORTA REGISTER for the 6 i/o pins A0-A5. So bits 0-5 can be a 1 or a 0 (1 being enable weak pull up).
So are you saying the syntax for this would be...
#CHIP 12f1840, 32
DIR PORTA.0 IN
DIR PORTA.1 IN
DIR PORTA.2 IN
DIR PORTA.3 IN
DIR PORTA.4 IN
DIR PORTA.5 IN
WPU0=0
WPU1=1
WPU2=1
WPU3=0
WPU4=0
WPU5=1
REST OF PROGRAM...
END
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Syntax looks good, except you would use your specific 12f1840 pull up register bits (my example was for a 12f683). When addressing the register bits individually, you only need to initialize those pins in the register that are used. Say you had input buttons on PortA, and wanted just pins 1,2,5 to be pulled up then:
Dir PortA.1 In
Dir PortA.2 In
Dir PortA.5 In
WPUA1 = 1
WPUA2 = 1
WPUA5 = 1
But sometimes it is easier to visualize, and as a shorthand way to code, when setting the whole register :
Excellent!!! Thanks for your help on this. Is there anywhere you can point me where this type of information is documented so I can learn this stuff without bothering everyone?
For instance, why would setting direction be
DIR PORT A.1 IN
and pull ups not be
WPUA.1 = 1
How do you find this type of syntax information?
Last edit: viscomjim 2015-02-03
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Keep asking away, it's not a problem. Always nice to see if the Help file, or forum, has been searched prior to posting. The data sheets can be a bit intimidating for those just starting, but are invaluable.
If you breadboard your 12f1840, or have some other development board, it is easy to link together the basic concepts (adc, uart, I2C, etc.) thru small experiments. Using an empirical approach is a good one I think.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The assembler allows you to address it both ways. So it comes down to a preference, or a coding practice? Their are bit names for register values that are not as obvious as when dealing with the Port(s).
Take the Fixed Voltage Reference (FVR) module for instance. This comes in handy for battery operations when the Vdd varies over time and the need for an accurate adc reference. One wants to conserve battery capacity so it's a good idea to put the device to sleep before the next adc measurement. Toggling the FVRCON, FVREN bit before sleep gives reduces energy requirements prior to sleep.
'So enable the FVRCON module
FVRCON.7 = 1 'Or, Set FVRCON.7 On
'Or
FVREN = 1 'Or, Set FVREN ON
...
...
...
'And disable FVRCON before setting device to sleep
FVRCON.7 = 0
'Or
FVREN = 0
'So which way is easiest to remember?
A look to Help/Variable Operations/Set command deals with variable.bit (On/Off).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
it is easier to visualize
Basic uses its own syntax. If it has its own definition of port pins direction, pullup should be defined with same, like manner. For example dir pin out|in|pullup. I seem.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Is there a way to configure the internal pull up resistors on the pic?
Thanks!!!!
Yes of course. GCB does a lot of things, but if you don't see a particular function in the help file, it is likely not addressed. Take a stroll to the GPIO/Additional Pin Functions section of your device data sheet, to get info on the WPU register.
So this comes under the heading of manual settings. On more complicated projects, this can happen a lot. And, familiarity with data sheet and the device.dat file becomes necessary. Set the pin direction to input, and then enable by setting the weak pullup bit, WPU1=1, WPU2=1, or?
I checked the data sheet for the pic12f1840 and there is the WPUA: WEAK PULL-UP PORTA REGISTER for the 6 i/o pins A0-A5. So bits 0-5 can be a 1 or a 0 (1 being enable weak pull up).
So are you saying the syntax for this would be...
Syntax looks good, except you would use your specific 12f1840 pull up register bits (my example was for a 12f683). When addressing the register bits individually, you only need to initialize those pins in the register that are used. Say you had input buttons on PortA, and wanted just pins 1,2,5 to be pulled up then:
But sometimes it is easier to visualize, and as a shorthand way to code, when setting the whole register :
Excellent!!! Thanks for your help on this. Is there anywhere you can point me where this type of information is documented so I can learn this stuff without bothering everyone?
For instance, why would setting direction be
DIR PORT A.1 IN
and pull ups not be
WPUA.1 = 1
How do you find this type of syntax information?
Last edit: viscomjim 2015-02-03
Keep asking away, it's not a problem. Always nice to see if the Help file, or forum, has been searched prior to posting. The data sheets can be a bit intimidating for those just starting, but are invaluable.
If you breadboard your 12f1840, or have some other development board, it is easy to link together the basic concepts (adc, uart, I2C, etc.) thru small experiments. Using an empirical approach is a good one I think.
The assembler allows you to address it both ways. So it comes down to a preference, or a coding practice? Their are bit names for register values that are not as obvious as when dealing with the Port(s).
Take the Fixed Voltage Reference (FVR) module for instance. This comes in handy for battery operations when the Vdd varies over time and the need for an accurate adc reference. One wants to conserve battery capacity so it's a good idea to put the device to sleep before the next adc measurement. Toggling the FVRCON, FVREN bit before sleep gives reduces energy requirements prior to sleep.
A look to Help/Variable Operations/Set command deals with variable.bit (On/Off).