8 years, 11 months ago.

NUCLEO F091RC PA2/3 PINS

Hi, I am not able to make the above two pins on the board to work as digital I/Os Is there any setting I am missing? My code is as follows:

#include "mbed.h"

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

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

// CONTROL SYSTEM OUTPUTS DEFINED HERE
DigitalOut FWDL(PC_8);
DigitalOut REVL(PC_6);
DigitalOut WHS(PC_5);
DigitalOut RCHG(PA_12);
DigitalOut RDISG(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.05);
    while (true) {
        FWDL=0;
        REVL=0;
        WHS=0;
        RCHG=0;
        RDISG=0;
        CSHOUT=0;
        COMPOUT=0;
        GER=0;
        GES=0;
        D_MAN=0;
        BSVOUT=0;
        F=0;
        R=0;
        H=0;
        M=0;
        L=0;
                    wait(1);
        FWDL=1;
        REVL=1;
        WHS=1;
        RCHG=1;
        RDISG=1;
        CSHOUT=1;
        COMPOUT=1;
        GER=1;
        GES=1;
        D_MAN=1;
        BSVOUT=1;
        F=1;
        R=1;
        H=1;
        M=1; // not working
        L=1; // not working

        
        // 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, 11 months ago.

PA2/PA3 are used for the serial port (by way of the ST-Link) to the host PC. The pins you assign for Serial pc(USBTX,USBRX) are the same and will be disabled when you afterwards assign them as DigitalOut. The hardware on the nucleos usually disconnects PA2/PA3 from the D0/D1 pins on the arduino header. There are some solderbridges to reconnect them if you like, but that will lead to a short with the serial-to-host of the ST-Link unless you remove another pair of solderbridges.

Accepted Answer