8 years, 2 months ago.

NUCLEO F091RC board PULLUP question

My following code should make pull-up enable on PF_0/PC_14/PC_15 but I am reading 0v on these pins. Can someone help me point out what might be wrong. Thanks

#include "mbed.h"

Ticker toggle_led_ticker;
Serial pc(USBTX,USBRX);
DigitalOut led1(LED1);

// CONTROL SYSTEM INPUTS DEFINED HERE
//DigitalIn  FSHIN(PA_14);
//DigitalIn  CSHIN(PA_15);
//DigitalIn  RTCIN(PB_7);
//DigitalIn  COMPIN(PC_13);
DigitalIn  GHIN(PC_14);
DigitalIn  MPSIN(PC_15);
DigitalIn  BPSIN(PF_0);
//DigitalIn  SBCIN(PF_1);
//DigitalIn  BSVIN(PC_2);

// CONTROL SYSTEM OUTPUTS DEFINED HERE
DigitalOut FWDL(PC_8);
DigitalOut REVL(PC_6);
DigitalOut WHS(PC_5);
DigitalOut RNCHG(PA_12);
DigitalOut RNDISG(PA_11);
DigitalOut CSHOUT(PB_12);
DigitalOut COMPOUT(PB_11);
DigitalOut GER(PB_2);
DigitalOut GES(PB_1);
DigitalOut D_MAN(PB_15);
DigitalOut BSVOUT(PB_14);
DigitalOut F(PB_13);
DigitalOut R(PC_4);
DigitalOut H(PA_10);
DigitalOut M(PA_2);
DigitalOut L(PA_3);


void toggle_led() {
    led1 = !led1;
}

int main() {
    // ENGAGE PULLUPS ON ALL INPUTS
/*    FSHIN.mode(PullUp);
    CSHIN.mode(PullUp);
    RTCIN.mode(PullUp);
    COMPIN.mode(PullUp);
 */
   GHIN.mode(PullUp);
    MPSIN.mode(PullUp);
    BPSIN.mode(PullUp);

 //   SBCIN.mode(PullUp);
 //   BSVIN.mode(PullUp);

    pc.baud(115200);
    // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms)
    toggle_led_ticker.attach(&toggle_led, 0.5);
    while (true) {
        // Do other things...
//        pc.printf("This program runs since %d seconds.\n", i++);
        pc.printf("CPU SystemCoreClock is %d Hz\r\n", SystemCoreClock);
        wait(1);
    }
}

1 Answer

8 years, 2 months ago.

Isolate your code by placing a:

while(1);

after the 3 lines which apply the pull-up resistor onto the respective port pins. Compile and re-test. Do you now see the pull-up resistor being applied onto the respective pins ? If yes, then something after this initialization is breaking the logic.

Post your results after testing.

Thanks Sanjiv. I did some research and it turns out PF_0 is oscillator input from St-Link MCU and 32KHz crystal is attached to PC_14/15. That seems to be the problem. I am selecting 3 other pins as a result. Thanks again for trying to help.

posted by D J 10 Jan 2016