Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 11 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, 11 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.