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

PIC12F510 and PORT_B_PULLUPS()

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



Joined: 21 Oct 2005
Posts: 291

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

PIC12F510 and PORT_B_PULLUPS()
PostPosted: Mon Mar 26, 2007 7:37 am     Reply with quote

I'm trying to turn on the pull-ups on a PIC12F510 - I copy the command from the 12F510.H file, but the compiler doesn't recognize the command:
PORT_B_PULLUPS(TRUE);
I get the response:
Undefined identifier -- PORT_B_PULLUPS
(I also tried PORT_A_PULLUPS...)

That this is a bug, right?
I use compiler version 3.236

Thanks.
drh



Joined: 12 Jul 2004
Posts: 192
Location: Hemet, California USA

View user's profile Send private message

PostPosted: Mon Mar 26, 2007 8:05 am     Reply with quote

"TRUE" is what it dosen't like. Read the 12F510 header file again.
_________________
David
frequentguest
Guest







PostPosted: Mon Mar 26, 2007 8:08 am     Reply with quote

Change the commands to lowercase. CCS functions are generally in all lowercase characters.
guy



Joined: 21 Oct 2005
Posts: 291

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

PostPosted: Mon Mar 26, 2007 8:11 am     Reply with quote

TRUE should be ok.
I also tried 1, and also to use a value for individual pullups (although the 12F510 doesn't support it) and none works.
The header file doesn't give an example, and according to the help, TRUE is ok.
More ideas, or an example how to use the function?
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Mar 26, 2007 8:23 am     Reply with quote

The compiler help file states that you should use setup_counters() to set the weak pull-ups. I've never used them on the 12F series PIC's so I can't say if that's how it should be done. Possibly, instead of using the built-in command you might need to set a register manually.

Ronald
Ttelmah
Guest







PostPosted: Mon Mar 26, 2007 10:08 am     Reply with quote

This is one of those lovely ones, where you can understand CCS getting it wrong. If you look at the data sheet for the chip family, the 16F506, has a 'port B pullup' bit. However the 12F510, instead has a 'general purpose pullup' bit. Unfortunately whoever was scanning the data sheet to implement the required functions, failed to see this, so has assumed the chip does not support 'pullups'.
As another poster has said, on this chip, the bit is accessed through the same configuration register as the timer prescaler. So:
Code:

#define ENABLEPULLUPS (0)
#define DISABLEPULLUPS (128)

//Then use

SETUP_TIMER_0(RTCC_DIV_1 | ENABLEPULLUPS);

With whatever 'timer' setting you actually want.

Best Wishes
guy



Joined: 21 Oct 2005
Posts: 291

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

Horribly - it works!
PostPosted: Mon Mar 26, 2007 10:15 am     Reply with quote

Horribly - it works!
Thanks Ttelmah
It also means that whenever someone uses SETUP_TIMER_0 (to setup timer 0) it turns on the pullups by default!

I hope they already fixed this in newer versions. BIG BUG. BIG NO-NO.
Laughing
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