View previous topic :: View next topic |
Author |
Message |
morebudwiser
Joined: 17 Oct 2005 Posts: 26
|
pic12f683 weak pullups |
Posted: Tue Sep 15, 2009 9:00 am |
|
|
Hi, I am trying to enable the internal weak pullups on a pic 12f683 but am not having any luck. I have tried the following code but it does not seem to work. Can anyone tell me how to do this? Many thanks. andrew
Code: |
setup_counters(RTCC_INTERNAL,RTTC_DIV_1);
|
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Sep 15, 2009 12:27 pm |
|
|
Use the port_a_pullups() function for this. Note that the parameter is
a bit mask. A '1' bit means that the pullup for the specified pin is
enabled and '0' means it's disabled. You can only enable pullups for
pins GP0, 1, 2, 4, and 5 (not GP3). Example:
Code: |
#include <12F683.h>
#fuses INTRC_IO, NOWDT, MCLR, PUT, BROWNOUT
#use delay(clock=8000000)
//=============================
void main()
{
port_a_pullups(0b00000101); // Enable pullups on GP0 and GP2
while(1);
}
|
|
|
|
Guest
|
|
Posted: Thu Sep 17, 2009 2:51 am |
|
|
hi have tried this and it does not seem to work either i am using compiler version 4.014 is this command compatible with this version.I am simulating the hardware in proteus ver7.2 many thanks for the help
Andrew |
|
|
dbotkin
Joined: 08 Sep 2003 Posts: 197 Location: Omaha NE USA
|
|
Posted: Thu Sep 17, 2009 8:10 am |
|
|
What's not working, exactly? Compiler error message, or WPUs not appearing to work? I have been using weak pull-ups on 12F683s for quite a while, every compiler version I've used has done it properly. Can you post your code? |
|
|
Ttelmah Guest
|
|
Posted: Thu Sep 17, 2009 8:50 am |
|
|
Yes.
Obvious comments are:
Won't work on pin A3.
They are _weak_ can be as low as 50uA.
Remember pins have to be programmed as inputs (default), before they work. This includes turning off the ADC, and the comparator on the pins.
Best Wishes |
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Thu Sep 17, 2009 9:22 am |
|
|
when in doubt - my favorite 100ua pullup ( or down) technique is a 47K resistor from the pin to Vdd ( or Vss)
then ANY pin can have a pullup(down) from the instant of power on
- just don't do that to a programming mode pin
sorry i couldn't "resist" commenting |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Sep 17, 2009 11:51 am |
|
|
Quote: | I am using compiler version 4.014 is this command compatible with this version |
The .LST file code is basically the same as 4.099. It should be working.
Quote: | I am simulating the hardware in proteus ver7.2 |
It's either Proteus or your design that's causing the problem.
Or, something in your larger program (that you're not showing us)
including possible compiler bugs (vs. 4.014) for that code. |
|
|
|