CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

port_b_pullups() and PIC10F2xx

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
Eddy71ua



Joined: 23 Sep 2009
Posts: 55
Location: Ukraine

View user's profile Send private message Visit poster's website

port_b_pullups() and PIC10F2xx
PostPosted: Sat Oct 28, 2023 6:25 am     Reply with quote

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: 9205
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Oct 28, 2023 7:28 am     Reply with quote

which PIC ?
I doubt any 10fxx PIC HAS a PortB

222 doesn't...,just checked.
Ttelmah



Joined: 11 Mar 2010
Posts: 19459

View user's profile Send private message

PostPosted: Sat Oct 28, 2023 7:52 am     Reply with quote

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: 9205
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Oct 28, 2023 8:09 am     Reply with quote

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: 19459

View user's profile Send private message

PostPosted: Sat Oct 28, 2023 12:06 pm     Reply with quote

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: 9205
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Sat Oct 28, 2023 5:41 pm     Reply with quote

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

View user's profile Send private message Visit poster's website

PostPosted: Sun Oct 29, 2023 7:48 am     Reply with quote

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: 19459

View user's profile Send private message

PostPosted: Sun Oct 29, 2023 8:38 am     Reply with quote

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: 1933
Location: Norman, OK

View user's profile Send private message

PostPosted: Sun Oct 29, 2023 11:02 am     Reply with quote

In this post PCM shows how to set the OPTION register bits where the GPPU bit (Port Pullups) is located.

http://www.ccsinfo.com/forum/viewtopic.php?t=50324&highlight=10f20%2A+option
_________________
Google and Forum Search are some of your best tools!!!!
Ttelmah



Joined: 11 Mar 2010
Posts: 19459

View user's profile Send private message

PostPosted: Sun Oct 29, 2023 12:52 pm     Reply with quote

That was for a very old compiler that didn't do this for you.
However worth knowing the alternatives. Very Happy
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group