View previous topic :: View next topic |
Author |
Message |
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
port_b_pullups() and PIC10F2xx |
Posted: Sat Oct 28, 2023 6:25 am |
|
|
I'm trying in the code to apply the command
Code: |
port_b_pullups(True);
|
for PIC10F2xx and get error message:
Quote: |
*** Error 12 "F:\UAV\TouchSNS\TouchSNS200.c" Line 18(15,16): Undefined identifier -- port_b_pullups |
But ih header file present line
Code: |
Discrete I/O Functions: SET_TRIS_x(), OUTPUT_x(), INPUT_x(), PORT_x_PULLUPS()
|
I'm surprised by that fact. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Oct 28, 2023 7:28 am |
|
|
which PIC ?
I doubt any 10fxx PIC HAS a PortB
222 doesn't...,just checked. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sat Oct 28, 2023 7:52 am |
|
|
Actually they do Jay.
The GPIO port is called Port B on these chips (designed to confuse!).
However read the manual. Note it's comment about which chips
this function supports.
Quote: |
Availability:
Only 14 and 16 bit devices (PCM and PCH). (Note: use SETUP_COUNTERS on PCB parts).
|
The point is that the pullups are not setup the same way on these chips.
Unlike the bigger PIC's where this s software settable using register bit
in the normal registers, these chips have this enabled using the option
register. This register controls the timers, and this option.
setup_counters
The option in the setup_counters, is to turn them off.
They are on GP0, 1 & 3 only.
Use setup_counters with the options to setup the timers, and they will
be turned on. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Oct 28, 2023 8:09 am |
|
|
dang, this dinosaur IS confused! 10f220/222 only refers to GPIO port (GP0..3) never says PORTB.... sigh
if anything it'd be called Port A, the FIRST port on the PIC
maybe he's using another 10F PIC ??
too many PICS, too little time....
cheers
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sat Oct 28, 2023 12:06 pm |
|
|
No the I/O is on port B on this chip.
If you look at the register addresses, the GPIO port is on the addresses
normally used by port B.
It is silly, but explains why he was trying to use the port B function.
However the key is that on these chips, this is not the function to enable
the pull-ups. The manual does explain this. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9241 Location: Greensville,Ontario
|
|
Posted: Sat Oct 28, 2023 5:41 pm |
|
|
and here I thought computers were 'logical'....
One port and it's offset from the beginning of the alphabet by one letter....
arrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrgh..
of should that be
brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrgh..
I'd like to got back to quartz windowed PICs and 20MA Teletypes please.
Jay |
|
|
Eddy71ua
Joined: 23 Sep 2009 Posts: 55 Location: Ukraine
|
|
Posted: Sun Oct 29, 2023 7:48 am |
|
|
GPIO port in small PIC10F controllers is called port_b, but I was confused by the fact that in the haser file the control of the port pull-up resistors is there, but you can't add it to the program |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sun Oct 29, 2023 8:38 am |
|
|
You can. You have to use the setup_counters function. Setup any counter
option, and the pull-ups will be enabled, _unless_ you add
DISABLE_PULLUPS to the setting. (or setup_wdt).
It is annoyingly illogical, but the problem is the bit to control the pull-ups
on all of these chips is inside a register that controls the counters
(and watchdog). So it is setup_wdt, or setup_counters that sets it. '0' turns
these on, so there is an option to disable these, but use no option for this
and just setup a counter, and these will be turned on. These bits are all
in the 'Option' register. |
|
|
dyeatman
Joined: 06 Sep 2003 Posts: 1934 Location: Norman, OK
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19537
|
|
Posted: Sun Oct 29, 2023 12:52 pm |
|
|
That was for a very old compiler that didn't do this for you.
However worth knowing the alternatives. |
|
|
|