View previous topic :: View next topic |
Author |
Message |
guy
Joined: 21 Oct 2005 Posts: 297
|
PIC12F510 and PORT_B_PULLUPS() |
Posted: Mon Mar 26, 2007 7:37 am |
|
|
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
|
|
Posted: Mon Mar 26, 2007 8:05 am |
|
|
"TRUE" is what it dosen't like. Read the 12F510 header file again. _________________ David |
|
|
frequentguest Guest
|
|
Posted: Mon Mar 26, 2007 8:08 am |
|
|
Change the commands to lowercase. CCS functions are generally in all lowercase characters. |
|
|
guy
Joined: 21 Oct 2005 Posts: 297
|
|
Posted: Mon Mar 26, 2007 8:11 am |
|
|
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
|
|
Posted: Mon Mar 26, 2007 8:23 am |
|
|
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
|
|
Posted: Mon Mar 26, 2007 10:08 am |
|
|
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: 297
|
Horribly - it works! |
Posted: Mon Mar 26, 2007 10:15 am |
|
|
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.
|
|
|
|