Internal pull-down resistors not working

Anyone else having problems with the internal pull-down resistors not working?

I’m setting pins P1_2 to P1_7 as inputs with pull-down enabled.

setDigitalInput(12,1);
setDigitalInput(13,1);
setDigitalInput(14,1);
setDigitalInput(15,1);
setDigitalInput(16,1);
setDigitalInput(17,1);
setPort1PullType(0);

Then, every 50ms I print their values

if (usbComTxAvailable() >= 64) {
  printf("%u %u %u %u %u %u\r\n", P1_2, P1_3, P1_4, P1_5, P1_6, P1_7);
}

Needless to say, the Wixel’s GPIOs are not connected to anything. I’m getting “0 1 0 0 1 0”. What’s weird is that when I try another Wixel I get “0 0 0 0 1 0”. Should I take this to mean that the pull-down resistors are broken? I should note that when I change the code to enable pull-up resistors (setPort1PullType(1)) all inputs are high.

Hello.

I am sorry you are having trouble with the Wixel. I tried to reproduce the problem here, but I could not.

Here is the code I compiled:

#include <wixel.h>
#include <usb.h>
#include <usb_com.h>
#include <stdio.h>

void putchar(char c)
{
    usbComTxSendByte(c);
}

void main()
{
    systemInit();
    usbInit();

    setDigitalInput(12, 1);
    setDigitalInput(13, 1);
    setDigitalInput(14, 1);
    setDigitalInput(15, 1);
    setDigitalInput(16, 1);
    setDigitalInput(17, 1);
    setPort1PullType(0);

    while(1)
    {
        static uint16 lastSampleTime;

        boardService();
        usbComService();

        if ((uint16)(getMs() - lastSampleTime) > 50 && usbComTxAvailable() >= 64)
        {
            lastSampleTime = getMs();
            printf("%u %u %u %u %u %u\r\n", P1_2, P1_3, P1_4, P1_5, P1_6, P1_7);
        }
    }
}

I compiled it using commit e837d08 of the Wixel SDK (the latest commit on github right now) and SDCC 3.4.0 for Windows. It outputs “0 0 0 0 0 0” when nothing is connected to the I/O lines, but I can make any of those numbers go to 1 by connecting an I/O pin to 3V3. I also used a multimeter to measure the current that flows into each pull-down resistor when it is connected to 3V3, and I got about 150 uA, as expected.

To rule out any potential issues with your compiler or code, I have attached the compiled WXL file that was generated from the code above:

test.wxl (18.7 KB)

Could you try running that file on your Wixel and see if you get the same results? You can write it to the Wixel by running:

wixelcmd write test.wxl

–David

Hi David. Thanks for providing that test script. Here are the results with my two Wixels.

Wixel #1
My code outputs: 0 1 0 0 1 0
Your code outputs: 0 1 0 0 0 0

Wixel #2
My code outputs: 0 0 0 0 1 0
Your code outputs: 0 0 0 0 0 0

I figure there are two things going on.
(1) Wixel #1 has a pull down resistor on P1_3 that doesn’t work.
(2) My program is doing something to P1_6. I tracked this down and it turns out I forgot to remove some code that was initializing UART 1 (P1_6 is the TX for UART 1). But, the call to uart1Init happens before the calls to setDigitalInput and setPort1PullType. So, shouldn’t it get overridden?

It does sound like something is wrong with Wixel #1. It could be that the P1_3 pull-down resistor is broken, or that something else is pulling the line high, or the digital input does not work. Maybe P1_3 is shorted to VALT, a 5V node that runs near it. If you measure the voltage on P1_3 with a multimeter, what reading do you get? If you connect P1_3 to GND through an appropriate resistor (220 Ohms to 1000 Ohms), does the reading of P1_3 from the test script change from 1 to 0, and does that affect the voltage on the line? Was the Wixel generally working for you before you noticed this problem? What have you used it for, and was P1_3 connected to anything?

Regarding the UART1 TX line, it is common for microcontroller peripherals to override the configuration of an I/O pin while they are enabled, by design. Your results indicate that this is true for the CC2511’s UART, but if you want more confirmation then it is probably documented somewhere in the CC2511 datasheet.

–David

I checked and P1_3 is not shorted to VALT. The voltage measures 2.15V.

After connecting to ground through a resistor, it works and outputs “0”. The voltage measures 385mV.

The Wixel worked just fine before this. I didn’t notice any problems (but I also wasn’t using P1_3). The previous application was to use the Wixel to add radio functionality to an Arduino.

Thanks for your help.

Thank you for the information. Unfortunately, it sounds like something is weakly pulling up P1_3, but it is strong enough to override the pull-down resistor.

–David