chipKIT® Development Platform

Inspired by Arduino™

Internal pullups

Created Tue, 09 Apr 2013 19:50:37 +0000 by majenko


majenko

Tue, 09 Apr 2013 19:50:37 +0000

Do my eyes deceive me, or is internal pull-up support on MPIDE completely missing?! :o

I can see nothing in the core, nor in any of the variants to do anything at all with internal pull-ups.

This is a fundamental facility that has been around in the Arduino since the year dot (or at least since comma - certainly before semicolon).

Yes, it's a little more tricky on the PIC32, as the pull-ups are tied in with the change notification, but it's perfectly possible to use them without having to use enable change notification. It would mean adding an extra table to the variant data to say which digital pin is associated with which CN pin, but that's not a problem, is it?

In my local wiring_digital.c I have added:

// If we are in input mode, then control the CN pullup resistor
    if (iop->tris.reg & bit) {
        cn = digitalPinToCN(pin);
        if (cn != NOT_CN_PIN) {
            if (val == HIGH) {
                CNPUESET = 1<<cn;
            } else {
                CNPUECLR = 1<<cn;
            }
        }
    } else {

        //* Determine if this is an output compare pin. If so,
        //* we need to make sure PWM output is off.

Along with defs for NOT_CN_PIN and a def for digitalPinToCN a-la the others in the Board_Defs,h file, and it works.

digitalWrite(x, HIGH) when in input mode now turns on the pull-up resistor.

Of course, it really needs pinMode(X, INPUT_PULLUP) implementing too... Plus using _BV() in the #define and not just the CN pin number, and scrapping the 1<< would be more efficient as well...


Jacob Christ

Wed, 10 Apr 2013 04:28:07 +0000

Sounds cool you should pull the repo make the changes to the code and do a pull request.

Jacob


majenko

Wed, 10 Apr 2013 08:26:19 +0000

I'm already working from the repo, but mine contains extra customisations on top - I'll have to pull a fresh copy I guess.

No idea how you do a "pull request", or a push request for that matter ;)


majenko

Wed, 10 Apr 2013 12:27:49 +0000

Ok, so I have done the changes in a clean repo (and done them properly, with a _PGM[] table, _BV() values and all ;) ) with the change notification table created for the Uno32 variant (all I have here to test on).

Now, how do I get that into the repo? I never use git if I can help it, so I'm a bit in the dark here. ;)


Jacob Christ

Wed, 10 Apr 2013 13:14:40 +0000

To do a pull request you need to have a github account.

First you clone the repository in you github account then clone localy.

Make the changes localy then push to your github account.

Within github there is an option to make a pull request. Once selected it will send a request to Rick Anderson whom will vet the changes and merge or throw them back.


If that all seems too daunting then you can just post an issue to github and attach your changes.

This however puts extra work on Rick whom is already in desperate need of cloning.

Jacob


majenko

Wed, 10 Apr 2013 13:20:21 +0000

Hmmm... I don't see an option to clone it - I see one to fork it, is that the one?

Ok, I think it is - forked, and now cloning it locally (again). I'll know in about 6 hours if it's worked ;) (github seems a bit slow today)


majenko

Wed, 10 Apr 2013 14:48:39 +0000

Ok, committed and pushed to my fork, and pull request created.