chipKIT® Development Platform

Inspired by Arduino™

Internal Pull-Up Resistors?

Created Sat, 16 Jul 2011 02:27:47 +0000 by ron.dunn


ron.dunn

Sat, 16 Jul 2011 02:27:47 +0000

Are pull-up resistors enabled in the same manner as Arduino?

On Arduino, setting a pin to INPUT then setting its value HIGH enables an internal pull-up resistor, ie:

pinMode (myPin,INPUT);
  digitalWrite (myPin,HIGH);

I'm asking because I'm getting spurious signals on inputs. Even waving my hand near the wires in question can trigger a random input value. That reminds me of an early Arduino experience before I learned about internal pull-ups.

A bit of research on Pic32 suggests that RxPU registers control internal pull-ups, but I can't find reference to these registers in the Pic32 Arduino Core libraries.


ron.dunn

Sat, 16 Jul 2011 04:11:53 +0000

Answered my own question: Pull-up resistors don't work the same as Arduino.

  1. Not all pins have pull-up resistors available.

  2. The pinMode/digitalWrite combination in the previous post doesn't affect pull-ups in Max32.

If you need pull-up resistors on input pins you'll need to add them externally.

No big deal. I had a bunch of 10k resistors in my parts box. Just something to watch if you're moving a project that uses input switches from Arduino to Max32.


KurtE

Wed, 23 Nov 2011 21:28:43 +0000

I am in the process of converting the PS2X_LIB from Arduino to Uno32 and I am trying to verify that this is correct?

If so it would be nice if the WIKI or the like mentioned it (http://www.chipkit.org/wiki/index.php?title=ChipKIT_Uno32&oldid=242)

I am new to PIC32, but my impression was that the chips may have a weak PU and weak PD resistor that can be enabled on IO pins. Is this true? Is there an easy way for some one to make use of it?

Thanks Kurt


WestfW

Thu, 24 Nov 2011 00:34:31 +0000

it looks like the pins capable of generating a pin change interrupt ("change notification" pins) also have a configurable pullup. These are rather randomly distributed, and it looks like most of them show up on the analog pins.

I don't see anything at all about pulldowns. I think some of the ARM chips have both pullups and pulldowns on all digital pins (STM32F, for example.)


Jacob Christ

Thu, 24 Nov 2011 22:33:44 +0000

I am in the process of converting the PS2X_LIB from Arduino to Uno32 and I am trying to verify that this is correct?
If so it would be nice if the WIKI or the like mentioned it (http://www.chipkit.org/wiki/index.php?title=ChipKIT_Uno32&oldid=242)

There is a library status page here:

http://www.chipkit.org/wiki/index.php?title=Library_Status

If your work is posted somewhere you should update the wiki yourself... We would all appreciate it.

Does this lib work over USB or bluetooth or both?

Jacob


KurtE

Fri, 25 Nov 2011 15:15:51 +0000

Hi, I thought I replied yesterday, but it appears like my posting was lost...

I re-looked and the Pic32 used in the UNO32 does not have PD resistors, I did not check the Mega32 version... I decided for now I would simply use an external resistor on the data line and yesterday I did get the library to limp along.

Should maybe take this to a new thread, but some more background information and issues I ran into include:

This library was created by Bill Porter for the Arduino: http://www.billporter.info/?p=240 I have used PS2 controllers on other platforms, especially for robots sold by http://www.Lynxmotion.com. They communicate using an SPI type interface. Whenever I have questions about how the PS2's communicate/work I usually go up to the site: http://www.curiousinventor.com/guides/ps2

Some issues I ran into in making it run on the UNO32 is that he is not using digitalWrite and digitalRead to talk to the 4 IO pins as these ran too slow. So he had his init code convert the IO pins into the appropriate Port and Mask and then when he is talking to the device, he sets or clears or tests the appropriate bit. So I needed to convert this to the PIC32 port stuff. First pass I unwound how digitalWrite worked and did part at startup and then set and cleared the bits. I used the last released IDE for this code. But I see that the current test build has changed this... So may convert to this.

Once I got things to compile I hooked up logic analyzer and used his test sketch and found I was not getting proper response from PS2, this is when I started looking at the PU issue.

Last I found the test program would hang or die. Took a bit of time, but found that the following, would fault:

unsigned char PS2data[21];
...
buttons = *(uint16_t*)(PS2data+3);

My assumption processor faulted with some form of data alignment fault... Fixed it to do this instead:

buttons =  (uint16_t)(PS2data[4] << 8) + PS2data[3];

Now the test program appears to be running. Probably needs to be cleaned up some and then integrated with my main code that I was going to try out on the UNO32 (Hex Robot using Lynxmotion Phoenix code that I ported to run on Arduinos.). Also probably need to share this information with Bill Porter to see if he would like to integrate it into his main code or fork it...

Kurt