Report
6 years, 2 months ago.

set mode to pullUp not working in object constructor

I can write code normally to enable or set pullUp mode on any input pin normally. However, i have written this code in a class and it does not seem to work. (the measured voltage was a low abt 0.16V). the code for the constructor is:

TouchScreenADS7843::TouchScreenADS7843(PinName PIN_SDI,PinName PIN_SDO,PinName PIN_CLK,PinName PIN_CS,PinName PIN_IRQ)
        : _PIN_CS(PIN_CS),_PIN_IRQ(PIN_IRQ), spi(PIN_SDI,PIN_SDO,PIN_CLK),_led(LED1)
{
    _PIN_CS=1;
    _PIN_IRQ.mode(PullUp);
    _led = 1;
    //spi.format(8,2);
}

and in the main I create an instance using:

TouchScreenADS7843 touch(p11,p12,p13,p10,p21);

So p21 should now be an input with pullUp enabled. I have no other refference to p21 in my code, and the measured voltage is a low. if in my code i write normally:

DigitalIn testpin(p21);
testpin.mode(PullUp);

it works!! but not with the class. Any idea why...?

TouchScreenADS7843::TouchScreenADS7843(PinName PIN_SDI,PinName PIN_SDO,PinName PIN_CLK,PinName PIN_CS,PinName PIN_IRQ)
        : _PIN_CS(PIN_CS),_PIN_IRQ(PIN_IRQ), spi(PIN_SDI,PIN_SDO,PIN_CLK),_led(LED1)
{
    _PIN_CS=1;
    _PIN_IRQ.mode(PullUp);
    _led = 1;
    //spi.format(8,2);
}

How and where was _PIN_IRQ declared in your header file?

Are you calling any other method of the touchscreen that could pull the irq low?

Maybe the ADS7843 device pulls it low by default until you read from it.

Do you measure a '1' on the CS pin

posted by Wim Huiskamp 28 Jan 2013

Thanks for your quick response. I figured out the problem though. i had actually a line of code hdden that created a Pwm object from the same pin.

posted by Jeremy Hall 28 Jan 2013
Comment on this question
Be the first to answer this question.

To post an answer, please log in.